electron/patches/node/fix_handle_possible_disable...

38 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 2 Oct 2023 16:03:43 +0200
Subject: fix: handle possible disabled SharedArrayBuffer
It's possible for SharedArrayBuffer to be disabled with the -no-harmony-sharedarraybuffer
flag, and so we should guard uses with a check for potential undefined-ness.
This should be upstreamed to Node.js.
diff --git a/lib/internal/crypto/webidl.js b/lib/internal/crypto/webidl.js
index 9f5340c223902c5ff61def05e8a4f470b4f328e8..d6dbfa482f9ebff3f99fb810e072cf9a03d1cd4d 100644
--- a/lib/internal/crypto/webidl.js
+++ b/lib/internal/crypto/webidl.js
@@ -183,7 +183,10 @@ function isNonSharedArrayBuffer(V) {
return ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V);
}
+// SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer.
function isSharedArrayBuffer(V) {
+ if (SharedArrayBuffer === undefined)
+ return false;
return ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V);
}
diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js
index 4460042d7bfbb8286a9b2abcbfb9e44f21b5d944..027a2de1878d5f09dc5d44b1b21af7163ea1b999 100644
--- a/lib/internal/main/worker_thread.js
+++ b/lib/internal/main/worker_thread.js
@@ -112,6 +112,7 @@ port.on('message', (message) => {
require('internal/worker').assignEnvironmentData(environmentData);
+ // SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer.
if (SharedArrayBuffer !== undefined) {
// The counter is only passed to the workers created by the main thread,
// not to workers created by other workers.