Make node:worker_threads independent of expose_global_message_channel flag#6069
Merged
petebacondarwin merged 1 commit intomainfrom Feb 13, 2026
Merged
Conversation
… 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
commented
Feb 13, 2026
Merged
9 tasks
jasnell
approved these changes
Feb 13, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
node:worker_threadsmodule was previously importingMessageChannelandMessagePortfromglobalThis, which meant it only worked when theexpose_global_message_channelcompatibility flag was enabled.This change introduces a new internal module (
cloudflare-internal:messagechannel) that exposesMessageChannelandMessagePortfor use by built-in modules, independent of the global flag.Changes
MessageChannelModuleC++ class inmessagechannel.hcloudflare-internal:messagechannelas an internal module inmodules.hnode:worker_threadsto import from the internal module instead ofglobalThisexpose_global_message_channelfrom worker_threads testsMessageChannel === globalThis.MessageChanneltest assertion conditionalTesting
bazel test //src/workerd/api/node/tests:worker_threads-nodejs-test@- all 22 tests pass without theexpose_global_message_channelflagRelated
Unblocks cloudflare/workers-sdk#12043 which needs
worker_threadsto work without requiring the global flag.