From 93bcb30c3e84694d9df0d59fb15bd5bdb4617b2a Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 2 Oct 2023 10:57:09 +0200 Subject: [PATCH] fix: `BroadcastChannel` initialization location (#40049) fix: `BroadcastChannel` initialization location (#37421) * fix: BroadcastChannel initialization location * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/node/.patches | 1 + ...dcastchannel_initialization_location.patch | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 patches/node/lib_fix_broadcastchannel_initialization_location.patch diff --git a/patches/node/.patches b/patches/node/.patches index 988022f07881..cb8962f5a128 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -48,3 +48,4 @@ tls_ensure_tls_sockets_are_closed_if_the_underlying_wrap_closes.patch test_deflake_test-tls-socket-close.patch net_fix_crash_due_to_simultaneous_close_shutdown_on_js_stream.patch net_use_asserts_in_js_socket_stream_to_catch_races_in_future.patch +lib_fix_broadcastchannel_initialization_location.patch diff --git a/patches/node/lib_fix_broadcastchannel_initialization_location.patch b/patches/node/lib_fix_broadcastchannel_initialization_location.patch new file mode 100644 index 000000000000..4a53a3b2457d --- /dev/null +++ b/patches/node/lib_fix_broadcastchannel_initialization_location.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shelley Vohr +Date: Mon, 27 Feb 2023 12:56:15 +0100 +Subject: lib: fix BroadcastChannel initialization location + +Refs https://github.com/nodejs/node/pull/40532. + +Fixes a bug in the above, wherein BroadcastChannel should have been +initialized in bootstrap/browser instead of bootstrap/node. That +inadvertently made it such that there was incorrect handling of the +DOM vs Node.js implementations of BroadcastChannel. + +This will be upstreamed. + +diff --git a/lib/internal/bootstrap/browser.js b/lib/internal/bootstrap/browser.js +index 5be4dd6176482c724455cbbeeaa9680e849a091b..29ccee75d77da072735032f0a25363ac88a023ba 100644 +--- a/lib/internal/bootstrap/browser.js ++++ b/lib/internal/bootstrap/browser.js +@@ -12,6 +12,10 @@ const { + } = require('internal/util'); + const config = internalBinding('config'); + ++// Non-standard extensions: ++const { BroadcastChannel } = require('internal/worker/io'); ++exposeInterface(globalThis, 'BroadcastChannel', BroadcastChannel); ++ + // https://console.spec.whatwg.org/#console-namespace + exposeNamespace(globalThis, 'console', + createGlobalConsole()); +diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js +index 13ea68c96fd415f976aab0f291a1b7c688db1c58..0ca3de08fffb344c0330ce0f8d28b2d3d0b24350 100644 +--- a/lib/internal/bootstrap/node.js ++++ b/lib/internal/bootstrap/node.js +@@ -238,10 +238,6 @@ const { + queueMicrotask, + } = require('internal/process/task_queues'); + +-// Non-standard extensions: +-const { BroadcastChannel } = require('internal/worker/io'); +-exposeInterface(globalThis, 'BroadcastChannel', BroadcastChannel); +- + defineOperation(globalThis, 'queueMicrotask', queueMicrotask); + + const timers = require('timers');