Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger isn't stopped at the debugger; statement when debugging using --inspect #10457

Closed
maxkoretskyi opened this issue Dec 26, 2016 · 8 comments
Labels
inspector Issues and PRs related to the V8 inspector protocol question Issues that look for answers.

Comments

@maxkoretskyi
Copy link

maxkoretskyi commented Dec 26, 2016

v6.9.2:
Windows10 x64:

When debugging with Chrome using $ node --inspect filename feature described here, the debugger isn't stopped at the debugger; statement as stated in the same manual

Inserting the statement debugger; into the source code of a script will enable a breakpoint at that position in the code:

for the $ node debug filename feature.

Is behavior different for the --inspect feature and debugger; statement is not supported?

@mscdex mscdex added inspector Issues and PRs related to the V8 inspector protocol question Issues that look for answers. labels Dec 26, 2016
@targos
Copy link
Member

targos commented Dec 26, 2016

debugger; statements are supported by node --inspect. However, they are ignored until the debugger is connected. You probably have to use the --debug-brk flag as well to pause the application at the start and have the time to open the developer tools.

@maxkoretskyi
Copy link
Author

maxkoretskyi commented Dec 26, 2016

Got it, thanks! So in this case $ node debug myscript.js the debugger is connected immediately so that I don't need to pass --debug-brk, correct?

@eugeneo
Copy link
Contributor

eugeneo commented Dec 27, 2016

$ node debug is not using the inspector protocol.

@maxkoretskyi
Copy link
Author

@eugeneo, so is my understanding correct that if --inspect is used, the debugger; statements are ignored until the debugger is connected. However, if $ node debug is used, the inspector protocol is not used, and debugger is stopped at the debugger; statements even before the debugger is connected?

@gibfahn
Copy link
Member

gibfahn commented Dec 28, 2016

@MaximusK That's correct. If you want to match node debug behaviour, use node --inspect --debug-brk as @targos mentioned.

@GeorgeTaveras1231
Copy link

Update on this. The flag has changed recently to --inspect-brk. So:

node --inspect-brk

@crtassos
Copy link

crtassos commented Oct 26, 2020

Hi max i had the same issue. I tried "node inspect app.js" to start the debugger using the inspector protocol without the two dashes "--" and it worked. I used the chrome devtools with chrome://inpsect

Reference: https://nodejs.org/api/debugger.html -- node -v v12.19.0

@HonmaMeikodesu
Copy link

Hi max i had the same issue. I tried "node inspect app.js" to start the debugger using the inspector protocol without the two dashes "--" and it worked. I used the chrome devtools with chrome://inpsect

Reference: https://nodejs.org/api/debugger.html -- node -v v12.19.0

Things work differently between node --inspect and node inspect, see docs here. Both node --inspect and node inspect will set up an inspector agent for debugging but the latter one will enable Node CLI as a inspector client. On the other hand the former one doesn't arrange a specific debugger, which could be devtools or your IDE, for you. Therefore there might be some underlyings mechanics related to inspector clients that cause the difference you mentioned, after all in your scenario, devtools isn't the first debugger that connect to your inspector agent but Node CLI is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inspector Issues and PRs related to the V8 inspector protocol question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

8 participants