src: disconnect inspector before exiting out of fatal exception
So that coverage, .etc are properly written in case of a normal fatal exception. PR-URL: https://github.com/nodejs/node/pull/29611 Fixes: https://github.com/nodejs/node/issues/29570 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com>
This commit is contained in:
parent
c5f5f84a33
commit
b2634238d8
@ -978,6 +978,9 @@ void TriggerUncaughtException(Isolate* isolate,
|
||||
|
||||
// Now we are certain that the exception is fatal.
|
||||
ReportFatalException(env, error, message, EnhanceFatalException::kEnhance);
|
||||
#if HAVE_INSPECTOR
|
||||
profiler::EndStartedProfilers(env);
|
||||
#endif
|
||||
|
||||
// If the global uncaught exception handler sets process.exitCode,
|
||||
// exit with that code. Otherwise, exit with 1.
|
||||
|
7
test/fixtures/v8-coverage/throw.js
vendored
Normal file
7
test/fixtures/v8-coverage/throw.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
const a = 99;
|
||||
if (true) {
|
||||
const b = 101;
|
||||
} else {
|
||||
const c = 102;
|
||||
}
|
||||
throw new Error('test');
|
@ -35,6 +35,24 @@ function nextdir() {
|
||||
assert.strictEqual(fixtureCoverage.functions[0].ranges[1].count, 0);
|
||||
}
|
||||
|
||||
// Outputs coverage when error is thrown in first tick.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, nextdir());
|
||||
const output = spawnSync(process.execPath, [
|
||||
require.resolve('../fixtures/v8-coverage/throw')
|
||||
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
|
||||
if (output.status !== 1) {
|
||||
console.log(output.stderr.toString());
|
||||
}
|
||||
assert.strictEqual(output.status, 1);
|
||||
const fixtureCoverage = getFixtureCoverage('throw.js', coverageDirectory);
|
||||
assert.ok(fixtureCoverage, 'coverage not found for file');
|
||||
// First branch executed.
|
||||
assert.strictEqual(fixtureCoverage.functions[0].ranges[0].count, 1);
|
||||
// Second branch did not execute.
|
||||
assert.strictEqual(fixtureCoverage.functions[0].ranges[1].count, 0);
|
||||
}
|
||||
|
||||
// Outputs coverage when process.exit(1) exits process.
|
||||
{
|
||||
const coverageDirectory = path.join(tmpdir.path, nextdir());
|
||||
|
Loading…
x
Reference in New Issue
Block a user