-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
exit CLI debugger automatically #40982
Comments
As far as I can tell, there isn't. What's the use case here? I'm having a hard time imagining a situation where it is desirable, much less essential, that If adding a feature for this is desirable, it seems like the place to start might be here: node/lib/internal/debugger/inspect.js Lines 267 to 272 in 43e1278
|
Interesting! I'm in the opposite place - I'm sure there is a good use for breaking immediately (perhaps attaching an external tool or something?) but I can't really work out when or why I would need to do that. I wonder if we're coming at the idea of what debuggers are useful for from different angles. In #40857 (comment) you pointed out that Python, when called with In Python I use the debugger like this (without passing any extra arguments):
#40982 (comment) was aimed at recreating this experience in Node.js, both visually and interactively, although it seems now that there might be two patterns of use to consider. The thing I'm currently working on that brought this to light is running multiple unit test scripts from the command line, although I can imagine wanting this sort of behaviour in all sorts of command line applications. A key thing this provides is a way to conditionally bring up the debugger. A script with randomised input failing every so often is a good example of when I would like to break and inspect deeper. If my code never executes a Hope that's a bit clearer. |
You can get part of the way there with |
Originally posted by @Spakman in #40857 (comment)
Given this
debugger.js
:Running
NODE_INSPECT_RESUME_ON_START=1 node inspect debugger.js
correctly skips the first line, instead breaking on thedebugger;
statement. I'd expect the firstconsole.log
output to appear directly in STDOUT rather than after the debug shell's<
(since thedebugger;
statement hasn't been executed yet). While I would find that behaviour cleaner, this isn't really the end of the world since if I'm wanting to step through code then I'm likely a bit less concerned about output correctness.Here's the output from that command:
A bigger issue for me is that the debug shell is both brought up automatically without any
debugger;
statements (causing what I'd consider in this case to be malformed output) and doesn't terminate without user input. With thisno_debugger.js
, runningNODE_INSPECT_RESUME_ON_START=1 node inspect no_debugger.js
gives this output:Here's the output:
In an ideal world, I'd expect running this
no_debugger.js
script to behave exactly as if I hadn't passed theinspect
argument.While it wouldn't solve any output issues, is there perhaps another environment variable that I'm missing to disconnect the debugger automatically when the script exits?
The text was updated successfully, but these errors were encountered: