lib_fix_broadcastchannel_initialization_location.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Shelley Vohr <[email protected]>
  3. Date: Mon, 27 Feb 2023 12:56:15 +0100
  4. Subject: lib: fix BroadcastChannel initialization location
  5. Refs https://github.com/nodejs/node/pull/40532.
  6. Fixes a bug in the above, wherein BroadcastChannel should have been
  7. initialized in bootstrap/browser instead of bootstrap/node. That
  8. inadvertently made it such that there was incorrect handling of the
  9. DOM vs Node.js implementations of BroadcastChannel.
  10. This will be upstreamed.
  11. diff --git a/lib/internal/bootstrap/browser.js b/lib/internal/bootstrap/browser.js
  12. index 5be4dd6176482c724455cbbeeaa9680e849a091b..29ccee75d77da072735032f0a25363ac88a023ba 100644
  13. --- a/lib/internal/bootstrap/browser.js
  14. +++ b/lib/internal/bootstrap/browser.js
  15. @@ -12,6 +12,10 @@ const {
  16. } = require('internal/util');
  17. const config = internalBinding('config');
  18. +// Non-standard extensions:
  19. +const { BroadcastChannel } = require('internal/worker/io');
  20. +exposeInterface(globalThis, 'BroadcastChannel', BroadcastChannel);
  21. +
  22. // https://console.spec.whatwg.org/#console-namespace
  23. exposeNamespace(globalThis, 'console',
  24. createGlobalConsole());
  25. diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
  26. index 13ea68c96fd415f976aab0f291a1b7c688db1c58..0ca3de08fffb344c0330ce0f8d28b2d3d0b24350 100644
  27. --- a/lib/internal/bootstrap/node.js
  28. +++ b/lib/internal/bootstrap/node.js
  29. @@ -238,10 +238,6 @@ const {
  30. queueMicrotask,
  31. } = require('internal/process/task_queues');
  32. -// Non-standard extensions:
  33. -const { BroadcastChannel } = require('internal/worker/io');
  34. -exposeInterface(globalThis, 'BroadcastChannel', BroadcastChannel);
  35. -
  36. defineOperation(globalThis, 'queueMicrotask', queueMicrotask);
  37. const timers = require('timers');