Skip to content

Commit

Permalink
lib: do not crash using workers with disabled shared array buffers
Browse files Browse the repository at this point in the history
This allows the repl to function normally while using the
`--no-harmony-sharedarraybuffer` V8 flag.

Fixes: nodejs#39717

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
BridgeAR committed Nov 29, 2021
1 parent 265a47d commit cb4adab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/switches/does_own_process_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const rawMethods = internalBinding('process_methods');
process.abort = rawMethods.abort;
process.umask = wrappedUmask;
process.chdir = wrappedChdir;
process.cwd = wrappedCwd;
process.cwd = typeof SharedArrayBuffer === 'undefined' ? rawMethods.cwd : wrappedCwd;

if (credentials.implementsPosixCredentials) {
const wrapped = wrapPosixCredentialSetters(credentials);
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ let cwdCounter;

const environmentData = new SafeMap();

if (isMainThread) {
if (isMainThread && typeof SharedArrayBuffer !== 'undefined') {
cwdCounter = new Uint32Array(new SharedArrayBuffer(4));
const originalChdir = process.chdir;
process.chdir = function(path) {
Expand Down

0 comments on commit cb4adab

Please sign in to comment.