Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! repl: properly handle uncaughtException
  • Loading branch information
BridgeAR committed May 6, 2019
commit 488d03a73b6be4135be3955919712389280253c9
4 changes: 3 additions & 1 deletion test/parallel/test-repl-uncaught-exception-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ r.write(
r.close();

setTimeout(() => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use process.on('exit', ...) instead of setTimeout()? That will avoid a possible race condition, or if not that, at least the appearance of a possible race condition.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to verify the timing. Using process.on('exit', ...) has no timing guarantees.

const len = process.listenerCount('uncaughtException');
process.removeAllListeners('uncaughtException');
assert.strictEqual(len, 0);
assert(/ERR_INVALID_REPL_INPUT.*(?!Type)RangeError: abc/s.test(accum));
assert.strictEqual(process.listenerCount('uncaughtException'), 0);
}, 2);
Comment thread
BridgeAR marked this conversation as resolved.