GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: do not swallow uncaughtException errors in exit code tests · nodejs/node@718f6bc

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/common
    • process-exit-code-cases.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/common/process-exit-code-cases.js‎

Copy file name to clipboardExpand all lines: test/common/process-exit-code-cases.js
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,25 @@ function getTestCases(isWorker = false) {
6262
cases.push({ func: changeCodeInsideExit, result: 99 });
6363

6464
function zeroExitWithUncaughtHandler() {
65+
const noop = () => { };
6566
process.on('exit', (code) => {
66-
assert.strictEqual(process.exitCode, 0);
67+
process.off('uncaughtException', noop);
68+
assert.strictEqual(process.exitCode, undefined);
6769
assert.strictEqual(code, 0);
6870
});
69-
process.on('uncaughtException', () => { });
71+
process.on('uncaughtException', noop);
7072
throw new Error('ok');
7173
}
7274
cases.push({ func: zeroExitWithUncaughtHandler, result: 0 });
7375

7476
function changeCodeInUncaughtHandler() {
77+
const modifyExitCode = () => { process.exitCode = 97; };
7578
process.on('exit', (code) => {
79+
process.off('uncaughtException', modifyExitCode);
7680
assert.strictEqual(process.exitCode, 97);
7781
assert.strictEqual(code, 97);
7882
});
79-
process.on('uncaughtException', () => {
80-
process.exitCode = 97;
81-
});
83+
process.on('uncaughtException', modifyExitCode);
8284
throw new Error('ok');
8385
}
8486
cases.push({ func: changeCodeInUncaughtHandler, result: 97 });

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.