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

Debug: node.js does not terminate when debugging simple script #5831

Closed
bpasero opened this issue Apr 26, 2016 · 10 comments
Closed

Debug: node.js does not terminate when debugging simple script #5831

bpasero opened this issue Apr 26, 2016 · 10 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues

Comments

@bpasero
Copy link
Member

bpasero commented Apr 26, 2016

I have a very simple index.js file with a "console.log()" statement and run it via debugger. The debugger does not terminate though, but keeps running. I would expect the debugger to stop after the console.log.

@weinand @isidorn fyi

@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues labels Apr 26, 2016
@isidorn
Copy link
Contributor

isidorn commented Apr 26, 2016

This was like this since the beggining of time - I also see it in stable.
Forwarding to @weinand since the debug adapter does not send a terminate signal - it probably does not arrive from node

@joaomoreno
Copy link
Member

joaomoreno commented Apr 26, 2016

@isidorn Surely this hasn't been like this forever. If a program is done, it's done, and the debugger used to quit debugging. Now I just think the program is still alive when it isn't.

It's especially bad if you are debugging a node server which crashes. The debugger shows the user that it is still running but you cannot hit it with the web browser...

@isidorn
Copy link
Contributor

isidorn commented Apr 26, 2016

@joaomoreno I remember this was like this since at least 6 months, but I think since day 1. This is how node behaves @weinand can correct me here
For debugging other languages once they are done we exit the debugging session because their program terminates and the adapter sends the appropriate signal to vscode

@joaomoreno
Copy link
Member

joaomoreno commented Apr 26, 2016

No it's not.

Node stops executing when there is nothing more to execute; it continues executing otherwise (e.g. when a setTimeout or setInterval is still pending, or waiting for IO).

If a script contains

console.log('goodbye')

What you get by running node script.js is goodbye and the process exits.

@weinand
Copy link
Contributor

weinand commented Apr 26, 2016

@joaomoreno what you describe is the 'happy path' (non debug) mode of node.js.

Please run your one line snippet from above in debug mode from the command line:

node --debug-brk test.js 

and then attach node-inspector and run the program to the end. You will find that the node process does not exit.

So @isidorn is right: this has been like this forever.

Your statement from above 'It's especially bad if you are debugging a node server which crashes....' is unfounded because node server crashes are not affected by node running in debug mode.

@joaomoreno
Copy link
Member

I have to disagree, that behaviour just appears to be a bug that no one cares. A bit of searching yielded nodejs/node#1788 which they seem to be picking up soon. It's a bug since 0.12; version 0.10 actually behaves as I and Ben expect it to.

Since this is a bug in Node itself I propose to just close this issue.

@bpasero bpasero removed the bug Issue identified by VS Code Team member as probable bug label Jul 1, 2016
@millermatt
Copy link

millermatt commented Jun 28, 2017

Node team has replaced the debugging engine and even though the same behavior is observed they are encouraging more digging into the VSCode side.

nodejs/node#1788 (comment)

Is it possible to re-open this for more research?

@joaomoreno @weinand


Actual behavior
debug session does not stop when node script has finished running

Expected behavior
when a node script has finished running, the debug session should end

Steps to reproduce

  1. Open an empty folder in VSCode
  2. Add a default launch debug configuration (Debug->Add Configurations...)
  3. Create a .js file with contents console.log('test');
  4. Launch the debugger
  5. Observe that the debug toolbar stays active and indicates that the script is executing after 'test' has been written to the console

OS: Ubuntu 17.10 & MacOS Sierra
Node: v8.1.2
Editor: Visual Studio Code 1.13.1

@weinand
Copy link
Contributor

weinand commented Jun 28, 2017

The VS Code node debugger ends the debug session on receipt of a terminate event from the runtime.
If such an event is not received, VS Code cannot end the session.
It is as simple as that.

@roblourens do you receive a terminate event with the inspector protocol?

@roblourens
Copy link
Member

This is fixed in 1.14 - microsoft/vscode-node-debug2#11

@weinand
Copy link
Contributor

weinand commented Jun 28, 2017

@roblourens we should mention in the release notes that this long-standing node.js bug has been finally fixed and that this will show up for the inspector protocol.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

No branches or pull requests

6 participants