fix_handle_possible_disabled_sharedarraybuffer.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Shelley Vohr <[email protected]>
  3. Date: Mon, 2 Oct 2023 16:03:43 +0200
  4. Subject: fix: handle possible disabled SharedArrayBuffer
  5. It's possible for SharedArrayBuffer to be disabled with the -no-harmony-sharedarraybuffer
  6. flag, and so we should guard uses with a check for potential undefined-ness.
  7. This should be upstreamed to Node.js.
  8. diff --git a/lib/internal/crypto/webidl.js b/lib/internal/crypto/webidl.js
  9. index 9f5340c223902c5ff61def05e8a4f470b4f328e8..d6dbfa482f9ebff3f99fb810e072cf9a03d1cd4d 100644
  10. --- a/lib/internal/crypto/webidl.js
  11. +++ b/lib/internal/crypto/webidl.js
  12. @@ -183,7 +183,10 @@ function isNonSharedArrayBuffer(V) {
  13. return ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V);
  14. }
  15. +// SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer.
  16. function isSharedArrayBuffer(V) {
  17. + if (SharedArrayBuffer === undefined)
  18. + return false;
  19. return ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V);
  20. }
  21. diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js
  22. index 4460042d7bfbb8286a9b2abcbfb9e44f21b5d944..027a2de1878d5f09dc5d44b1b21af7163ea1b999 100644
  23. --- a/lib/internal/main/worker_thread.js
  24. +++ b/lib/internal/main/worker_thread.js
  25. @@ -112,6 +112,7 @@ port.on('message', (message) => {
  26. require('internal/worker').assignEnvironmentData(environmentData);
  27. + // SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer.
  28. if (SharedArrayBuffer !== undefined) {
  29. // The counter is only passed to the workers created by the main thread,
  30. // not to workers created by other workers.