summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Campailla <alexis@janeasystems.com>2013-12-06 08:58:15 -0800
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-01-20 09:00:14 -0800
commite12e72eb58c68b82f5bbd89e094cf7fb7b7e00c8 (patch)
treec8e8b5e44fc1c37c109c91c240f5d550aef7e828
parent574f71444c0f4c281e73b5effc4f0bffb42f9e96 (diff)
downloadnode-e12e72eb58c68b82f5bbd89e094cf7fb7b7e00c8.tar.gz
debug client: connect after child is ready
We now wait to connect to the debuggee until we know that its error stream has data, to ensure that the output message "connecting..... ok" appears after "Debugger listening on port xyz" I also increased the test timeout to let the more complex tests finish in time on Windows This change fixes the following unit tests on Windows: test-debugger-repl.js test-debugger-repl-term.js test-debugger-repl-utf8.js test-debugger-repl-restart.js
-rw-r--r--lib/_debugger.js20
-rw-r--r--test/debugger/helper-debugger-repl.js2
2 files changed, 12 insertions, 10 deletions
diff --git a/lib/_debugger.js b/lib/_debugger.js
index 4dd9f5363..f9e24768f 100644
--- a/lib/_debugger.js
+++ b/lib/_debugger.js
@@ -25,6 +25,7 @@ var util = require('util'),
vm = require('vm'),
repl = require('repl'),
inherits = util.inherits,
+ assert = require('assert'),
spawn = require('child_process').spawn;
exports.start = function(argv, stdin, stdout) {
@@ -1612,6 +1613,7 @@ Interface.prototype.trySpawn = function(cb) {
childArgs = this.args;
this.killChild();
+ assert(!this.child);
if (this.args.length === 2) {
var match = this.args[1].match(/^([^:]+):(\d+)$/);
@@ -1647,12 +1649,10 @@ Interface.prototype.trySpawn = function(cb) {
}
}
- if (!this.child) {
- this.child = spawn(process.execPath, childArgs);
+ this.child = spawn(process.execPath, childArgs);
- this.child.stdout.on('data', this.childPrint.bind(this));
- this.child.stderr.on('data', this.childPrint.bind(this));
- }
+ this.child.stdout.on('data', this.childPrint.bind(this));
+ this.child.stderr.on('data', this.childPrint.bind(this));
this.pause();
@@ -1709,8 +1709,10 @@ Interface.prototype.trySpawn = function(cb) {
client.connect(port, host);
}
- setTimeout(function() {
- self.print('connecting to port ' + port + '..', true);
- attemptConnect();
- }, 50);
+ this.child.stderr.once('data', function() {
+ setImmediate(function() {
+ self.print('connecting to port ' + port + '..', true);
+ attemptConnect();
+ });
+ });
};
diff --git a/test/debugger/helper-debugger-repl.js b/test/debugger/helper-debugger-repl.js
index 409e4f54d..6346457af 100644
--- a/test/debugger/helper-debugger-repl.js
+++ b/test/debugger/helper-debugger-repl.js
@@ -91,7 +91,7 @@ function startDebugger(scriptToDebug) {
});
quit();
- }, 5000).unref();
+ }, 10000).unref();
process.once('uncaughtException', function(e) {
console.error('UncaughtException', e, e.stack);