Skip to content

fix(ext/node): fix worker.terminate() return value and exit code#32168

Merged
bartlomieju merged 6 commits intodenoland:mainfrom
bartlomieju:fix/worker-threads-misc
Feb 15, 2026
Merged

fix(ext/node): fix worker.terminate() return value and exit code#32168
bartlomieju merged 6 commits intodenoland:mainfrom
bartlomieju:fix/worker-threads-misc

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

Two fixes to worker.terminate() behavior to match Node.js:

  • Return undefined when worker already exited: In Node.js, calling worker.terminate() after the worker has already exited resolves to undefined (the internal handle is null). Previously Deno always resolved to 0.
  • Use exit code 1 for forced termination: Node.js uses exit code 1 when a running worker is forcefully terminated via worker.terminate(). Previously Deno always used 0.

Enables 2 new node_compat tests:

  • test-worker-terminate-null-handler.js
  • test-worker-terminate-microtask-loop.js

Note: This PR is based on #32161 and should be merged after it.

Test plan

  • cargo test --test node_compat parallel -- --filter "test-worker-terminate" — all registered tests pass
  • No regressions in test-worker-dispose.mjs or other tests calling terminate()

🤖 Generated with Claude Code

bartlomieju and others added 4 commits February 14, 2026 12:54
In Node.js, calling worker.terminate() after the worker has already
exited resolves to undefined (the internal handle is null). Previously
Deno always resolved to 0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion

Node.js uses exit code 1 when a worker is forcefully terminated via
worker.terminate(). Previously Deno always used exit code 0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@Tango992 Tango992 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bartlomieju bartlomieju force-pushed the fix/worker-threads-misc branch from b1c0cda to a51fa04 Compare February 15, 2026 12:03
@bartlomieju bartlomieju merged commit 0c839b0 into denoland:main Feb 15, 2026
86 checks passed
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.

2 participants