SIGN IN SIGN UP
denoland / deno UNCLAIMED

A modern runtime for JavaScript and TypeScript.

0 0 16 Rust

fix: send BroadcastChannel messages before close (#34628)

Fixes a race where BroadcastChannel.postMessage deferred the
cross-worker send and then skipped it if the channel was closed before
the deferred callback ran. This made node:worker_threads
BroadcastChannel examples that call close() immediately after
postMessage() hang waiting for a message that was never sent.

The send is now committed to the shared broadcast queue before
postMessage() returns, while receiver dispatch remains asynchronous.
Added a node:worker_threads regression spec for the reported repro.

Closes denoland/divybot#362
Fixes https://github.com/denoland/deno/issues/31134

Verification:
- timeout 10s target/debug/deno run --allow-all
--unstable-broadcast-channel /tmp/orchid-362-repro.mjs
- env -u RUSTC_WRAPPER cargo test -p specs_tests
specs::node::worker_threads::broadcast_channel -- --nocapture
- target/debug/deno fmt --check
tests/specs/node/worker_threads/__test__.jsonc
tests/specs/node/worker_threads/broadcast_channel.mjs
- git diff --check

Note: ./tools/format.js --check on the touched files spawned dprint
plugin processes that did not exit in this workspace after reporting the
initial import formatting diff; the reported diff was applied, and the
new spec files pass deno fmt --check.

Co-authored-by: divybot <divybot@users.noreply.github.com>
Co-authored-by: Divy Srivastava <me@littledivy.com>
E
em committed
697bdb1affd0168f10328496358f782a1989643d
Parent: d11c5d0
Committed by GitHub <noreply@github.com> on 6/1/2026, 1:20:51 AM