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 — lib: honor setUncaughtExceptionCaptureCallback · nodejs/node@d58a466

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/process
    • execution.js
  • test/report
    • test-report-uncaught-exception-override.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/process/execution.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/execution.js
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,16 @@ function evalScript(name, body, breakFirstLine, print) {
9292
globalThis.module = origModule;
9393
}
9494

95-
const exceptionHandlerState = { captureFn: null };
95+
const exceptionHandlerState = {
96+
captureFn: null,
97+
reportFlag: false
98+
};
9699

97100
function setUncaughtExceptionCaptureCallback(fn) {
98101
if (fn === null) {
99102
exceptionHandlerState.captureFn = fn;
100103
shouldAbortOnUncaughtToggle[0] = 1;
104+
process.report.reportOnUncaughtException = exceptionHandlerState.reportFlag;
101105
return;
102106
}
103107
if (typeof fn !== 'function') {
@@ -108,6 +112,9 @@ function setUncaughtExceptionCaptureCallback(fn) {
108112
}
109113
exceptionHandlerState.captureFn = fn;
110114
shouldAbortOnUncaughtToggle[0] = 0;
115+
exceptionHandlerState.reportFlag =
116+
process.report.reportOnUncaughtException === true;
117+
process.report.reportOnUncaughtException = false;
111118
}
112119

113120
function hasUncaughtExceptionCaptureCallback() {
Collapse file

‎test/report/test-report-uncaught-exception-override.js‎

Copy file name to clipboard
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Flags: --report-uncaught-exception
2+
'use strict';
3+
// Test report is suppressed on uncaught exception hook.
4+
const common = require('../common');
5+
const assert = require('assert');
6+
const helper = require('../common/report');
7+
const tmpdir = require('../common/tmpdir');
8+
const error = new Error('test error');
9+
10+
tmpdir.refresh();
11+
process.report.directory = tmpdir.path;
12+
13+
// First, install an uncaught exception hook.
14+
process.setUncaughtExceptionCaptureCallback(common.mustCall());
15+
16+
// Make sure this is ignored due to the above override.
17+
process.on('uncaughtException', common.mustNotCall());
18+
19+
process.on('exit', (code) => {
20+
assert.strictEqual(code, 0);
21+
// Make sure no reports are generated.
22+
const reports = helper.findReports(process.pid, tmpdir.path);
23+
assert.strictEqual(reports.length, 0);
24+
});
25+
26+
throw error;

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.