Skip to content

fix(runtime): warn on unsupported web Worker options and fix recv panic#33310

Merged
bartlomieju merged 2 commits into
mainfrom
fix/worker-unsupported-options-warning
Apr 18, 2026
Merged

fix(runtime): warn on unsupported web Worker options and fix recv panic#33310
bartlomieju merged 2 commits into
mainfrom
fix/worker-unsupported-options-warning

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Summary

  • Emit a console warning when node-specific options (env, workerData) are passed to the web Worker() constructor, directing users to node:worker_threads instead. These options are silently ignored by web Workers, which can lead to subtle bugs like infinite worker recursion.
  • Replace handle_receiver.recv().unwrap() in op_create_worker with a proper error return, so a worker thread dying before initialization produces a JS error instead of a process panic.

Fixes #31058

Root cause

The issue reporter passed { env: { IS_WORKER: "true" } } to new Worker() (web worker). The web Worker constructor silently ignores env (it's a node:worker_threads option). The spawned worker couldn't detect it was a worker (process.env.IS_WORKER was never set), so it entered the main code path and recursively spawned more workers exponentially. This exhausted OS resources until Rust's thread initialization panicked trying to allocate a signal stack.

Test plan

  • New spec tests: tests/specs/worker/worker_unsupported_options/ — verifies warning for both env and workerData
  • Existing worker spec tests pass
  • Existing node:worker_threads spec tests pass
  • cargo check -p deno_runtime clean
  • JS lint clean

🤖 Generated with Claude Code

bartlomieju and others added 2 commits April 17, 2026 13:27
Emit a console warning when node-specific options like `env` or
`workerData` are passed to the web `Worker()` constructor, directing
users to `node:worker_threads` instead. These options are silently
ignored by web Workers, which can lead to subtle bugs like infinite
worker recursion (fixes #31058).

Also replace `handle_receiver.recv().unwrap()` in `op_create_worker`
with a proper error return, so a worker thread dying before
initialization produces a JS error instead of a process panic.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@bartlomieju
bartlomieju merged commit 33bee46 into main Apr 18, 2026
112 checks passed
@bartlomieju
bartlomieju deleted the fix/worker-unsupported-options-warning branch April 18, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deno crashes when using workers to traverse files

1 participant