From 8076de4ac4c58e850fd0c363617c2dcde088da38 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 31 Oct 2015 08:22:39 -0700 Subject: [PATCH 1/2] test: fix flaky test-debug-signal-cluster.js SmartOS sometimes munges output from `process._rawDebug()` but Windows can't use `console.error()` in the debug agent. So inject logic to chose the right thing based on platform. Fixes: https://github.com/nodejs/node/issues/2476 --- lib/_debug_agent.js | 9 ++++++++- test/parallel/parallel.status | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/_debug_agent.js b/lib/_debug_agent.js index 63c50357894b08..10d1adeb15e30e 100644 --- a/lib/_debug_agent.js +++ b/lib/_debug_agent.js @@ -20,7 +20,14 @@ exports.start = function start() { agent.listen(process._debugAPI.port, function() { var addr = this.address(); - process._rawDebug('Debugger listening on port %d', addr.port); + // SmartOS sometimes munges output from `process._rawDebug()` + // but Windows can't use `console.error()`. + // https://github.com/nodejs/node/issues/2476 + if (process.platform == 'win32') { + process._rawDebug('Debugger listening on port %d', addr.port); + } else { + console.error('Debugger listening on port %d', addr.port); + } process._debugAPI.notifyListen(); }); diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 69a154730658d2..9334614d5626d8 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -18,7 +18,6 @@ test-child-process-exit-code : PASS,FLAKY [$system==macos] [$system==solaris] # Also applies to SmartOS -test-debug-signal-cluster : PASS,FLAKY [$system==freebsd] test-net-socket-local-address : PASS,FLAKY From 6cc5743200c1e6ccb834978c3eb029359e103c7e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 31 Oct 2015 09:22:59 -0700 Subject: [PATCH 2/2] fixup: cjihrig comments --- lib/_debug_agent.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/_debug_agent.js b/lib/_debug_agent.js index 10d1adeb15e30e..cb397bcb8011fa 100644 --- a/lib/_debug_agent.js +++ b/lib/_debug_agent.js @@ -7,7 +7,12 @@ const Buffer = require('buffer').Buffer; const Transform = require('stream').Transform; exports.start = function start() { - var agent = new Agent(); + const agent = new Agent(); + + // SmartOS sometimes munges output from `process._rawDebug()` + // but Windows can't use `console.error()`. + // https://github.com/nodejs/node/issues/2476 + const log = process.platform === 'win32' ? process._rawDebug : console.error; // Do not let `agent.listen()` request listening from cluster master const cluster = require('cluster'); @@ -15,19 +20,12 @@ exports.start = function start() { cluster.isMaster = true; agent.on('error', function(err) { - process._rawDebug(err.stack || err); + log(err.stack || err); }); agent.listen(process._debugAPI.port, function() { - var addr = this.address(); - // SmartOS sometimes munges output from `process._rawDebug()` - // but Windows can't use `console.error()`. - // https://github.com/nodejs/node/issues/2476 - if (process.platform == 'win32') { - process._rawDebug('Debugger listening on port %d', addr.port); - } else { - console.error('Debugger listening on port %d', addr.port); - } + const addr = this.address(); + log(`Debugger listening on port ${addr.port}`); process._debugAPI.notifyListen(); });