Debugging
See original GitHub issueHere are some notes I put together while trying to get debugging working. I’m looking for suggestions on how to get this to work.
Environment
osx 10.11.2 node v4.4.7 npm@3.10.3 node-inspector@0.12.8 babel-watch@2.0.2
Node command line flag order
Does not work: node ./test.js --debug-brk
Works: node --debug-brk ./test.js
Ref: https://github.com/nodejs/node/blob/master/src/node.cc#L3420
Cannot change order of flags passed to babel-watch
Babel watch thinks that the first argument in babel-watch --debug-brk ./test.js
is a file.
The offending three lines begin at https://github.com/kmagiera/babel-watch/blob/master/babel-watch.js#L92
Args passed to babel watch don’t seem to influence node arguments on spawned node process (forking the runner.js script)
Am I correct in understanding that in runner.js, runMain just loads the modules? Ref: https://github.com/nodejs/node/blob/master/lib/module.js#L573 If this is true, then we cannot expect node arguments to be propagated at the point runMain is called. Ref: https://github.com/kmagiera/babel-watch/blob/master/runner.js#L87
Alternative attempt at passing node arguments to child process
Changing https://github.com/kmagiera/babel-watch/blob/master/babel-watch.js#L240 to
const app = fork(path.resolve(__dirname, 'runner.js'), {execArgv: ['--debug-brk']});
seems to do this to ps
26214 0.0 0.2 3671444 39284 s012 S+ 12:51AM 0:00.48 /Users/n/.nvm/versions/node/v4.4.7/bin/node --debug-brk /Users/n/P/node_modules/babel-watch/runner.js
26210 0.0 0.2 3104508 41884 s012 S+ 12:51AM 0:00.64 node /Users/n/P/node_modules/.bin/babel-watch ./test.js
26208 0.0 0.5 3121008 82492 s013 S+ 12:50AM 0:02.60 node /Users/n/P/node_modules/.bin/node-inspector
But this just stops at module.js:409 and then doesn’t even run the test script when unpaused.
This is the closest I’ve gotten so far.
Ref: https://github.com/nodejs/node/blob/master/lib/child_process.js#L39
Endnote
As an aside, I’m curious why you decided not to read from .babelrc or package.json.
Thanks for putting this together. I find it to be the nicest approach out there for loading transpiled files.
Issue Analytics
- State:
- Created 7 years ago
- Comments:20 (10 by maintainers)
None of the options above will work today.
--debug
is deprecated and attempting to use--inspect=0.0.0.0:9222
will be ignored and instead--inspect
will be passed, meaning you cannot configure it. For programs running in Docker, this means inspector will not be able to connect since debugger only allows container-local connections. On top of that, pressing CTRL+C will not abort the process and you must kill the process manually to stop babel-watch.Example:
Nothing happens here, and node inspector can connect but will be unable to actually debug anything or even do simple console commands. I also tried switching around
--
so it was:node --inspect=0.0.0.0:9222 -- node_modules/.bin/babel-watch test.js
with no mentionable change in behavior. Same goes for--debug
where I’m instead thrown a deprecation warning.Any plans on improving this?
We’re also stuck on this. We need to be able to bind the inspector on
0.0.0.0
.