Skip to content

Commit 7bac743

Browse files
princejwesleyrvagg
authored andcommitted
debugger: assert test before accessing this.binding
PR-URL: #5145 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 4dae8ca commit 7bac743

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/_debug_agent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function Agent() {
4848

4949
this.first = true;
5050
this.binding = process._debugAPI;
51+
assert(this.binding, 'Debugger agent running without bindings!');
5152

5253
var self = this;
5354
this.binding.onmessage = function(msg) {
@@ -57,7 +58,6 @@ function Agent() {
5758
};
5859

5960
this.clients = [];
60-
assert(this.binding, 'Debugger agent running without bindings!');
6161
}
6262
util.inherits(Agent, net.Server);
6363

test/parallel/test-debug-agent.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
5+
assert.throws(() => { require('_debug_agent').start(); },
6+
assert.AssertionError);

0 commit comments

Comments
 (0)