Wednesday, 15 January 2014

node.js - NodeJS: Debugging child process causes incomplete runs or skipped breakpoints -



node.js - NodeJS: Debugging child process causes incomplete runs or skipped breakpoints -

i'm using webstorm 8 debug scenario parent process forks child, , sends message.

to create kid process debuggable, i'm passing --debug or --debug-brk parameter.

webstorm picks child's port, i'm unable have debugging behave correctly.

here's sample code:

parent:

var proc = require('child_process').fork('./child.js', [], {execargv: ['--debug']}); proc.send({say: 'hello 1'}); settimeout(function () { proc.send({say: 'hello 2'}); }, 3000);

child:

console.log('child started'); process.on('message', function (msg) { console.log("child got message", msg); });

1) when running without debug mode , forking without --debug , without --debug-brk, code runs next output:

child started kid got message { say: 'hello 1' } kid got message { say: 'hello 2' }

2) when running in debug mode , forking --debug-brk code behaves differently - first message never arrives process, , output is:

debugger listening on port 62008 debugger listening on port 5858 kid started kid got message { say: 'hello 2' }

3) when running in debug mode , forking --debug both messages arrive, breakpoint within child's message handler fired sec message (hello 2). output :

debugger listening on port 62022 debugger listening on port 5858 kid started kid got message { say: 'hello 1' } kid got message { say: 'hello 2' }

basically, there seems 2 issues here: --debug-brk causing code run differently, , --debug causing breakpoints skipped.

what right way debug both parent , child, without modifying flow , ensuring breakpoints stopped on?

looks bug; logged web-12528, please vote it

node.js debugging intellij-idea webstorm

No comments:

Post a Comment