Skip to content

feat: add worker option to spawnTest - #67

Open
bavulapati wants to merge 1 commit into
nodejs:mainfrom
bavulapati:feat/spawn-test-worker
Open

feat: add worker option to spawnTest#67
bavulapati wants to merge 1 commit into
nodejs:mainfrom
bavulapati:feat/spawn-test-worker

Conversation

@bavulapati

@bavulapati bavulapati commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Adds spawnTest(file, { worker: true }), which runs the test file on a worker thread of the spawned child, plus a runtimeFeatures.worker flag to gate on. First consumer is the worker half of test_instance_data (#66).

Why an option on spawnTest rather than an in-process runInWorker: a native printf from an addon writes to fd 1 directly, bypassing a worker's piped JS-level stdout, so observing a secondary environment's native output means capturing the host process's stdout. Upstream wraps its worker in a child process for the same reason.

runtimeFeatures.worker is declared separately from spawn because the two are independent - a browser has workers but no subprocesses.

The worker inherits the child's execArgv, so harness globals reach it. Leaving the Worker without an error handler is deliberate: an unhandled worker error re-throws on the host thread, so a failing test file still exits non-zero with its stack on stderr. tests/harness/spawn-test-worker.js pins that, plus cwd.

@bavulapati
bavulapati force-pushed the feat/spawn-test-worker branch from 6d5aa66 to dd9a852 Compare July 31, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Need Triage

Development

Successfully merging this pull request may close these issues.

1 participant