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 doesnt stop when exiting extension development host #32990

Closed
chrisdias opened this issue Aug 22, 2017 · 13 comments
Closed

debugger doesnt stop when exiting extension development host #32990

chrisdias opened this issue Aug 22, 2017 · 13 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Milestone

Comments

@chrisdias
Copy link
Member

git clone https://github.com/microsoft/vscode-docker
cd vscode-docker && npm install
code-insiders .

F5 to launch the debugger
extension development host starts up
close the extension development host)

results:

  • the debugger is still running, i have to press stop to actually stop the debugger
  • pressing restart hangs with following message:

image

@chrisdias chrisdias added this to the August 2017 milestone Aug 22, 2017
@vscodebot vscodebot bot added the debug Debug viewlet, configurations, breakpoints, adapter issues label Aug 22, 2017
@weinand weinand added the bug Issue identified by VS Code Team member as probable bug label Aug 23, 2017
@weinand
Copy link
Contributor

weinand commented Aug 23, 2017

@bpasero I've debugged this on the debugger side and it seems that closing the EH window does neither terminate the EH node process nor does it send any broadcast events for this.

@weinand weinand assigned bpasero and unassigned roblourens, isidorn and weinand Aug 23, 2017
@bpasero
Copy link
Member

bpasero commented Aug 24, 2017

@weinand this seems to be a regression from us moving to --inspect, I cannot reproduce the hanging extension host when I do not pass over the --inspect-brk to the extension host on launch.

Could it be that the debugger needs to explicitly send some signal to the debuggee to signal the session is over and otherwise the process will never terminate?

@bpasero bpasero added the info-needed Issue requires more information from poster label Aug 24, 2017
@bpasero
Copy link
Member

bpasero commented Aug 24, 2017

/cc @alexandrudima because I know he refactored a lot of the extension host process recently to support restarting. I am not sure if there was any impact on how the process shutsdown (e.g. I see a newly introduced _cleanResources that seems to kill the extension host process on shutdown.

@weinand
Copy link
Contributor

weinand commented Aug 24, 2017

@bpasero yes, a terminate request from the debugger might be necessary.
@roblourens do you know something about this?

The problem is that the debugger doesn't know when the EH window's close button has been pressed. So we would at least need another broadcast event for this.

@weinand
Copy link
Contributor

weinand commented Aug 24, 2017

The issue is that process.exit() does not exit node if node has been started with --inspect.
Since I couldn't find any info about this behaviour I don't know whether this is a bug or feature.

@roblourens do you know anything about this? Could it be that there is a specific shutdown handshake between the runtime and the debugger is needed to exit the process properly?

Debugging this node program with the "inspector" protocol shows the same behaviour:

process.exit();
console.log("not reached");

The console.log statement is not reached but the node process doesn't exit.

Using process.kill(process.pid) in extensionHostMain.ts:29 instead of nativeExit(1) fixes the issue.

@alexandrudima @bpasero how should we proceed?

@bpasero
Copy link
Member

bpasero commented Aug 24, 2017

If that works, why not use process.kill if the extension host knows that it is being debugged?

@weinand
Copy link
Contributor

weinand commented Aug 24, 2017

Yes, if Rob has no better ideas I suggest that we use process.kill(process.pid) if in debug mode.

@roblourens
Copy link
Member

roblourens commented Aug 25, 2017

There was an issue in Node <8 where the process doesn't terminate or signal that it's complete until the debugger detaches. Now we get an event from node that the script has completed, and terminate the debugging session. This is probably related. I'm surprised that it impacts process.exit but I think process.kill is the right way to go.

@roblourens
Copy link
Member

If it's ugly, we can revisit it with an electron version that has a node 8 equivalent (1.7.5 says node 7.9?) and maybe remove it then.

@weinand
Copy link
Contributor

weinand commented Aug 25, 2017

@alexandrudima could you please add the process.kill(process.pid) workaround the way you like it? Thanks.

@weinand weinand removed the info-needed Issue requires more information from poster label Aug 25, 2017
@alexdima
Copy link
Member

This is the nodejs PR that introduced this --- nodejs/node#7252

@weinand
Copy link
Contributor

weinand commented Aug 25, 2017

@roblourens this means it is a feature and our "inspector" DA should really detach when process.exit() is called.
But probably you can only detach in node versions >= 8.0 because only there you get an event for the process.exit(), correct?

@roblourens
Copy link
Member

Correct. Original node2 issue: microsoft/vscode-node-debug2#11

It didn't occur to me that this would impact EH debugging, thanks for the investigation and fix. I opened #33196 to revisit this once Electron has Node 8.

@isidorn isidorn added the verified Verification succeeded label Sep 1, 2017
@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
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants