Skip to content

Commit 6a696d1

Browse files
seishunaddaleax
authored andcommitted
inspector: fix crash on exception
Fixes: #13438 PR-URL: #13455 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
1 parent 0ca4bd1 commit 6a696d1

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

src/inspector_agent.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,9 @@ void CallAndPauseOnStart(
371371
v8::MaybeLocal<v8::Value> retval =
372372
args[0].As<v8::Function>()->Call(env->context(), args[1],
373373
call_args.size(), call_args.data());
374-
args.GetReturnValue().Set(retval.ToLocalChecked());
374+
if (!retval.IsEmpty()) {
375+
args.GetReturnValue().Set(retval.ToLocalChecked());
376+
}
375377
}
376378

377379
// Used in NodeInspectorClient::currentTimeMS() below.
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
common.skipIfInspectorDisabled();
5+
6+
const assert = require('assert');
7+
const helper = require('./inspector-helper.js');
8+
const path = require('path');
9+
10+
const script = path.join(common.fixturesDir, 'throws_error.js');
11+
12+
13+
function setupExpectBreakOnLine(line, url, session) {
14+
return function(message) {
15+
if ('Debugger.paused' === message['method']) {
16+
const callFrame = message['params']['callFrames'][0];
17+
const location = callFrame['location'];
18+
assert.strictEqual(url, session.scriptUrlForId(location['scriptId']));
19+
assert.strictEqual(line, location['lineNumber']);
20+
return true;
21+
}
22+
};
23+
}
24+
25+
function testBreakpointOnStart(session) {
26+
const commands = [
27+
{ 'method': 'Runtime.enable' },
28+
{ 'method': 'Debugger.enable' },
29+
{ 'method': 'Debugger.setPauseOnExceptions',
30+
'params': {'state': 'none'} },
31+
{ 'method': 'Debugger.setAsyncCallStackDepth',
32+
'params': {'maxDepth': 0} },
33+
{ 'method': 'Profiler.enable' },
34+
{ 'method': 'Profiler.setSamplingInterval',
35+
'params': {'interval': 100} },
36+
{ 'method': 'Debugger.setBlackboxPatterns',
37+
'params': {'patterns': []} },
38+
{ 'method': 'Runtime.runIfWaitingForDebugger' }
39+
];
40+
41+
session
42+
.sendInspectorCommands(commands)
43+
.expectMessages(setupExpectBreakOnLine(0, script, session));
44+
}
45+
46+
function testWaitsForFrontendDisconnect(session, harness) {
47+
console.log('[test]', 'Verify node waits for the frontend to disconnect');
48+
session.sendInspectorCommands({ 'method': 'Debugger.resume'})
49+
.expectStderrOutput('Waiting for the debugger to disconnect...')
50+
.disconnect(true);
51+
}
52+
53+
function runTests(harness) {
54+
harness
55+
.runFrontendSession([
56+
testBreakpointOnStart,
57+
testWaitsForFrontendDisconnect
58+
]).expectShutDown(1);
59+
}
60+
61+
helper.startNodeForInspectorTest(runTests,
62+
undefined,
63+
undefined,
64+
script);

0 commit comments

Comments
 (0)