Skip to content

Commit 4162abb

Browse files
Eugene OstroukhovMylesBorins
authored andcommitted
inspector: check if connected before waiting
Fixes: #10093 PR-URL: #10094 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 3666879 commit 4162abb

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/inspector_agent.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,12 @@ bool AgentImpl::IsStarted() {
515515
}
516516

517517
void AgentImpl::WaitForDisconnect() {
518-
shutting_down_ = true;
519-
fprintf(stderr, "Waiting for the debugger to disconnect...\n");
520-
fflush(stderr);
521-
inspector_->runMessageLoopOnPause(0);
518+
if (state_ == State::kConnected) {
519+
shutting_down_ = true;
520+
fprintf(stderr, "Waiting for the debugger to disconnect...\n");
521+
fflush(stderr);
522+
inspector_->runMessageLoopOnPause(0);
523+
}
522524
}
523525

524526
#define READONLY_PROPERTY(obj, str, var) \
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
require('../common');
3+
const spawn = require('child_process').spawn;
4+
5+
const child = spawn(process.execPath,
6+
[ '--inspect', 'no-such-script.js' ],
7+
{ 'stdio': 'inherit' });
8+
9+
function signalHandler(value) {
10+
child.kill();
11+
process.exit(1);
12+
}
13+
14+
process.on('SIGINT', signalHandler);
15+
process.on('SIGTERM', signalHandler);

0 commit comments

Comments
 (0)