-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: error using
webcrypto.subtle.importKey()
(#40070)
fix: error using webcrypto.subtle.importKey()
- Loading branch information
1 parent
b0590b6
commit b3a1c6d
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
patches/node/fix_handle_possible_disabled_sharedarraybuffer.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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 be4d82086199855a10108528b3dacc663b839454..10c33bacc0529e12f52aaf1baf6d42489b2a75a7 100644 | ||
--- a/lib/internal/main/worker_thread.js | ||
+++ b/lib/internal/main/worker_thread.js | ||
@@ -108,6 +108,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. |