Skip to content

Commit

Permalink
Replace dummy initialization with optional chain
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Aug 15, 2022
1 parent 06a6f7e commit ae53bfc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/worker/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {flags, refs, sharedWorkerTeardowns} from './state.cjs';
import {isRunningInThread, isRunningInChildProcess} from './utils.cjs';

const currentlyUnhandled = setUpCurrentlyUnhandled();
let runner = Object.create(null);
let runner;

// Override process.exit with an undetectable replacement
// to report when it is called from a test (which it should never be).
Expand All @@ -37,7 +37,7 @@ async function exit(code, forceSync = false) {

process.exit = new Proxy(realExit, {
apply(fn, receiver, args) {
channel.send({type: 'internal-error', err: serializeError('Forced exit error', false, new Error('Unexpected process.exit()'), runner.file)});
channel.send({type: 'internal-error', err: serializeError('Forced exit error', false, new Error('Unexpected process.exit()'), runner?.file)});

// Make sure to extract the code only from `args` rather than e.g. `Array.prototype`.
// This level of paranoia is usually unwarranted, but we're dealing with test code
Expand Down

0 comments on commit ae53bfc

Please sign in to comment.