question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Here 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:closed
  • Created 7 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

7reactions
scarlaccommented, Jan 22, 2018

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:

14:16:52 ~/jobs/project ⚡️ node --inspect=0.0.0.0:9222 node_modules/.bin/babel-watch -- test.js
Debugger listening on ws://0.0.0.0:9222/0fdba86a-fafc-4178-9a25-004da4f2792e
For help see https://nodejs.org/en/docs/inspector
Starting inspector on 0.0.0.0:9222 failed: address already in use
^C^C^C

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?

5reactions
evertcommented, Feb 2, 2018

We’re also stuck on this. We need to be able to bind the inspector on 0.0.0.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is debugging? - TechTarget
Debugging, in computer programming and engineering, is a multistep process that involves identifying a problem, isolating the source of the problem and then ......
Read more >
Debugging - Wikipedia
In computer programming and software development, debugging is the process of finding and resolving bugs within computer programs, software, or systems.
Read more >
Debugging - Definition - The Economic Times
Definition: Debugging is the process of detecting and removing of existing and potential errors (also called as 'bugs') in a software code that...
Read more >
Software Engineering | Debugging - GeeksforGeeks
In the context of software engineering, debugging is the process of fixing a bug in the software. In other words, it refers to...
Read more >
What is Debugging? How to Debug Your Code for Beginners
Debugging can be defined as the process of finding the root of a problem in a code base and fixing it. Usually we'll...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found