Skip to content

Commit

Permalink
debugger: assert test before accessing this.binding
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
princejwesley authored and Myles Borins committed Mar 1, 2016
1 parent 4e0755c commit 139d6d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/_debug_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function Agent() {

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

var self = this;
this.binding.onmessage = function(msg) {
Expand All @@ -57,7 +58,6 @@ function Agent() {
};

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

Expand Down
6 changes: 6 additions & 0 deletions test/parallel/test-debug-agent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';
require('../common');
const assert = require('assert');

assert.throws(() => { require('_debug_agent').start(); },
assert.AssertionError);

0 comments on commit 139d6d9

Please sign in to comment.