-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Add ability to disable break on first line when using the CLI inspector #40857
Comments
@nodejs/diagnostics |
I'm generally +1 on this. |
I guess the obvious way to implement this would be as a command-line flag: |
I'm thinking in disable by default the break on first line and land it as major. What do you think? @Trott |
Does that conflict with the behavior most people would want and expect? Do CLI debuggers in general tend to break on or before the first executable statement by default? I'd be interested to know what the standard Python, Perl, and Ruby CLI debuggers do, for example. |
I suspect Perl and Ruby and interpreted/scripting languages in general do the same in their CLI debuggers, but correction is welcome. I personally would find a different behavior (in a CLI debugger) surprising, but I'm certainly open to the idea if it's the right thing to do. |
I would be -1 on making it the default. I don't think having |
Btw, I think we should still always break internally on first line, because otherwise there's a risk that the code with the breakpoint runs before we connect the inspector. An option to automatically continue after this initial pause SGTM. |
Yes, makes sense. |
It looks like there is already an undocumented environment variable that does this. Set @Spakman Can you test this and confirm that it works as you expect? If so, perhaps the solution is to document the environment variable. |
Using this seems to get us part way there, but it's still not behaving in the way I'd expect. Given this
Running Here's the output from that command:
A bigger issue for me is that the debug shell is both brought up automatically without any
Here's the output:
In an ideal world, I'd expect running this 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? |
Because the initial question was about "disable break on first line" and now we're talking about exiting the debugger automatically, I've opened a new issue for that in #40982. |
My apologies. I was caught up in my own goals and had conflated somewhat unrelated issues. A new conversation makes perfect sense. |
Oh, no apology necessary. Scope creep in a conversation is pretty natural. Just trying to keep individual issues from having long conversations attached to them if they are not required. |
Is your feature request related to a problem? Please describe.
I use Node.js to run unit tests in a (Linux) shell. The way this is set up to run is to evaluate each test script as a single invocation of Node.js in series. It's working great!
However, while I do have the ability to use a
debugger;
statement (when I invoke each test usingnode inspect a_test_file.js
) in these scripts to use the built-in CLI inspector, because of the forced breakpoint on the first line, the debug shell is activated for every test script, which quickly becomes tedious. I'm looking to run something likenode inspect a_test_file.js
and only have it bring up the debug shell if/when adebugger;
statement is executed.Describe the solution you'd like
While I do understand the need to break on the first line in many other situations, some method to disable it would be very useful in this circumstance. An environment varible or a command line argument to achieve this would both work well for me.
Describe alternatives you've considered
I'm not aware of any way to work around this.
The text was updated successfully, but these errors were encountered: