GeezerVison is showing github.com — src: disconnect inspector before exiting out of fatal exception · fredericp/node@b263423
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_errors.cc +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -978,6 +978,9 @@ void TriggerUncaughtException(Isolate* isolate, |
978 | 978 |
|
979 | 979 | // Now we are certain that the exception is fatal. |
980 | 980 | ReportFatalException(env, error, message, EnhanceFatalException::kEnhance); |
| 981 | +#if HAVE_INSPECTOR |
| 982 | + profiler::EndStartedProfilers(env); |
| 983 | +#endif |
981 | 984 |
|
982 | 985 | // If the global uncaught exception handler sets process.exitCode, |
983 | 986 | // exit with that code. Otherwise, exit with 1. |
|
Collapse file
Copy file name to clipboard +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +const a = 99; |
| 2 | +if (true) { |
| 3 | + const b = 101; |
| 4 | +} else { |
| 5 | + const c = 102; |
| 6 | +} |
| 7 | +throw new Error('test'); |
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-v8-coverage.js +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -35,6 +35,24 @@ function nextdir() { |
35 | 35 | assert.strictEqual(fixtureCoverage.functions[0].ranges[1].count, 0); |
36 | 36 | } |
37 | 37 |
|
| 38 | +// Outputs coverage when error is thrown in first tick. |
| 39 | +{ |
| 40 | + const coverageDirectory = path.join(tmpdir.path, nextdir()); |
| 41 | + const output = spawnSync(process.execPath, [ |
| 42 | + require.resolve('../fixtures/v8-coverage/throw') |
| 43 | + ], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } }); |
| 44 | + if (output.status !== 1) { |
| 45 | + console.log(output.stderr.toString()); |
| 46 | + } |
| 47 | + assert.strictEqual(output.status, 1); |
| 48 | + const fixtureCoverage = getFixtureCoverage('throw.js', coverageDirectory); |
| 49 | + assert.ok(fixtureCoverage, 'coverage not found for file'); |
| 50 | + // First branch executed. |
| 51 | + assert.strictEqual(fixtureCoverage.functions[0].ranges[0].count, 1); |
| 52 | + // Second branch did not execute. |
| 53 | + assert.strictEqual(fixtureCoverage.functions[0].ranges[1].count, 0); |
| 54 | +} |
| 55 | + |
38 | 56 | // Outputs coverage when process.exit(1) exits process. |
39 | 57 | { |
40 | 58 | const coverageDirectory = path.join(tmpdir.path, nextdir()); |
|