Skip to content

worker_threads: defer worker-side stdio/Console setup to first access - #34345

Closed
robobun wants to merge 5 commits into
mainfrom
farm/876bb94d/worker-threads-lazy-stdio
Closed

worker_threads: defer worker-side stdio/Console setup to first access#34345
robobun wants to merge 5 commits into
mainfrom
farm/876bb94d/worker-threads-lazy-stdio

setupWorkerStdio: shadow stdio slots conditionally, matching the getters

7d727b7
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 16, 2026 in 18m 3s

Code review found 1 important issue

Found 1 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 0
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/js/node/worker_threads.ts:487-490 require('node:console').Console is undefined in workers after lazy console rebind

Annotations

Check failure on line 490 in src/js/node/worker_threads.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

require('node:console').Console is undefined in workers after lazy console rebind

`require('node:console').Console` is now `undefined` inside workers: `node:console` is `export default globalThis.console`, and since it's no longer required at preload, its first evaluation triggers the lazy getter and caches a plain `new Console(...)` instance — which lacks `.Console`, `.write`, and `[Symbol.asyncIterator]`. Before this PR the preload's `require('node:console')` primed the module registry with the native console, so `const { Console } = require('console')` in a worker worked;