Skip to content

Make node:worker_threads independent of expose_global_message_channel flag#6069

Merged
petebacondarwin merged 1 commit intomainfrom
pbacondarwin/worker-threads-internal-messagechannel
Feb 13, 2026
Merged

Make node:worker_threads independent of expose_global_message_channel flag#6069
petebacondarwin merged 1 commit intomainfrom
pbacondarwin/worker-threads-internal-messagechannel

Conversation

@petebacondarwin
Copy link
Copy Markdown
Contributor

Summary

The node:worker_threads module was previously importing MessageChannel and MessagePort from globalThis, which meant it only worked when the expose_global_message_channel compatibility flag was enabled.

This change introduces a new internal module (cloudflare-internal:messagechannel) that exposes MessageChannel and MessagePort for use by built-in modules, independent of the global flag.

Changes

  • Add MessageChannelModule C++ class in messagechannel.h
  • Register cloudflare-internal:messagechannel as an internal module in modules.h
  • Update node:worker_threads to import from the internal module instead of globalThis
  • Add TypeScript type definitions for the internal module
  • Remove expose_global_message_channel from worker_threads tests
  • Make the MessageChannel === globalThis.MessageChannel test assertion conditional

Testing

  • Ran bazel test //src/workerd/api/node/tests:worker_threads-nodejs-test@ - all 22 tests pass without the expose_global_message_channel flag

Related

Unblocks cloudflare/workers-sdk#12043 which needs worker_threads to work without requiring the global flag.

… flag

The node:worker_threads module was previously importing MessageChannel and
MessagePort from globalThis, which meant it only worked when the
expose_global_message_channel compatibility flag was enabled.

This change introduces a new internal module (cloudflare-internal:messagechannel)
that exposes MessageChannel and MessagePort for use by built-in modules,
independent of the global flag.

Changes:
- Add MessageChannelModule C++ class in messagechannel.h
- Register cloudflare-internal:messagechannel as an internal module
- Update node:worker_threads to import from the internal module
- Add TypeScript type definitions for the internal module
- Remove expose_global_message_channel from worker_threads tests

This unblocks cloudflare/workers-sdk#12043 which needs worker_threads to
work without requiring the global flag.
@petebacondarwin petebacondarwin merged commit 37dc327 into main Feb 13, 2026
22 of 23 checks passed
@petebacondarwin petebacondarwin deleted the pbacondarwin/worker-threads-internal-messagechannel branch February 13, 2026 14:35
petebacondarwin added a commit to cloudflare/workers-sdk that referenced this pull request Feb 17, 2026
> Make node:worker_threads independent of expose_global_message_channel flag by @petebacondarwin in cloudflare/workerd#6069
petebacondarwin added a commit to cloudflare/workers-sdk that referenced this pull request Feb 17, 2026
> Make node:worker_threads independent of expose_global_message_channel flag by @petebacondarwin in cloudflare/workerd#6069
petebacondarwin added a commit to cloudflare/workers-sdk that referenced this pull request Feb 17, 2026
> Make node:worker_threads independent of expose_global_message_channel flag by @petebacondarwin in cloudflare/workerd#6069
petebacondarwin added a commit to cloudflare/workers-sdk that referenced this pull request Feb 17, 2026
> Make node:worker_threads independent of expose_global_message_channel flag by @petebacondarwin in cloudflare/workerd#6069
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