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

Extension debugging: stopping debug session doesn't close window #126911

Closed
weinand opened this issue Jun 22, 2021 · 23 comments
Closed

Extension debugging: stopping debug session doesn't close window #126911

weinand opened this issue Jun 22, 2021 · 23 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues on-release-notes Issue/pull request mentioned in release notes verified Verification succeeded
Milestone

Comments

@weinand
Copy link
Contributor

weinand commented Jun 22, 2021

Issue Type: Bug

  • debug "Mock Debug" extension
  • stop debug session by pressing red button in debug toolbar

Observe: extension window doesn't close

This problem doesn't occur with a simple "hello world" extension.


VS Code version: Code - Insiders 1.58.0-insider (6afedfd, 2021-06-21T05:14:03.949Z)
OS version: Darwin x64 20.5.0
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz (12 x 2900)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 5, 6, 6
Memory (System) 32.00GB (0.22GB free)
Process Argv --crash-reporter-id 785023c0-aeb7-4708-b29f-2c6aa9e59a8d
Screen Reader no
VM 0%
Extensions (25)
Extension Author (truncated) Version
mock-debug and 0.45.8
npm-intellisense chr 1.3.1
vscode-eslint dba 2.1.23
eslint-disable-snippets drK 1.3.0
tsl-problem-matcher eam 0.4.0
vscode-pull-request-github-insiders Git 2021.6.30916
csharp ms- 1.23.12
jupyter ms- 2021.7.960048241
remote-containers ms- 0.184.0
remote-ssh ms- 0.65.7
remote-ssh-edit ms- 0.65.7
remote-wsl ms- 0.58.2
vscode-remote-extensionpack ms- 0.21.0
azure-account ms- 0.9.8
cpptools ms- 1.5.0-insiders
js-debug-nightly ms- 2021.6.1617
vscode-github-issue-notebooks ms- 0.0.102
java red 0.79.2
vscode-lldb vad 1.6.4
vscode-java-debug vsc 0.34.0
vscode-java-dependency vsc 0.18.4
vscode-java-pack vsc 0.16.0
vscode-java-test vsc 0.30.0
vscode-maven vsc 0.31.0
gitblame wad 7.0.6
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383:30185418
pythonvspyt602:30291494
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256197
pythonvspyt639:30291487
pythontb:30258533
pythonvspyt551cf:30291413
vspre833:30321513
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscus158:30321503
pythonvsuse255:30319630
vscorehov:30301224
vscod805cf:30301675
pythonvspyt200:30323110
vscextlang:30310088
vsccppwt:30312692

@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues bug Issue identified by VS Code Team member as probable bug labels Jun 22, 2021
@isidorn isidorn added info-needed Issue requires more information from poster and removed bug Issue identified by VS Code Team member as probable bug labels Jun 22, 2021
@isidorn
Copy link
Contributor

isidorn commented Jun 22, 2021

This works just fine for me. I can not repro.
Here are my steps:

  1. Latest vscode insiders, latest mock debug
  2. Choose "Extension" launch config. Press F5 to start debugging
  3. Press red button -> window closes

Let me know what you are doing differently than me in this gif. Thanks!

recording (1)

@weinand
Copy link
Contributor Author

weinand commented Jun 23, 2021

@isidorn thanks for trying this.

Since I could reliably reproduce this problem, I tried all kinds of things in order to find the source of the problem: uninstalling all extensions, changing settings, restarting my computer, taking a coffee break.. ;-)

What helped in the end was deleting the Code - Insiders folder in ~/Library/Application Support/ which basically wipes all settings and browser state and caches. After doing this the problem no longer occurs.

Then I was looking into the other new issue #126924.
Since you saw that problem when running out of source, I did the same and ran Mock Debug in VS Code out of source. I could not reproduce your problem but I again saw the issue that the extension window would not close when stopping the debug session.

And again deleting the code-oss-dev folders in ~/Library/Application Support/ made the problem disappear.

So there seems to be an issue with persisted state but I have no idea why that affects the window close on debug session end...

@isidorn
Copy link
Contributor

isidorn commented Jun 24, 2021

@weinand if you can reproduce it would be interesting to understand if the signal to close the window is sent or not. I forgot if we send this from the debug session, or from the debug adapter.

@weinand
Copy link
Contributor Author

weinand commented Jun 24, 2021

@isidorn no, we don't close EH windows from the debug session. The window is closed because the extension host process is terminated.

@Jason3S
Copy link

Jason3S commented Jun 26, 2021

I have this issue too.
Although reloading using
image
seems to work.

When using a reload, I get an unhandled rejected promise in extensionHostProcess.js

return y.apply(b,h)}_remoteCall(a,p,h){if(this._isDisposed)return Promise.reject(k.canceled());

This is rather recent and is most likely unrelated.

@isidorn isidorn added the *duplicate Issue identified as a duplicate of another issue(s) label Aug 6, 2021
@weinand weinand reopened this Aug 10, 2021
@weinand
Copy link
Contributor Author

weinand commented Aug 10, 2021

@bpasero before giving up on this issue I would like to get your insights.
Could you please read my #126911 (comment) from above? Do you have an idea what is going on?

@bpasero
Copy link
Member

bpasero commented Aug 11, 2021

@weinand

no, we don't close EH windows from the debug session. The window is closed because the extension host process is terminated.

Trying to find that code again, can you point me to it?

If you have a reliable repro for this, can you try running with --verbose and check for main logs and window logs (maybe also devtools of that window) to see if an exception is raised or any veto?

@bpasero
Copy link
Member

bpasero commented Aug 12, 2021

Isn't it this code, which would suggest the window is closed based on an event from debug?

this._toDispose.add(this._extensionHostDebugService.onClose(event => {
if (this._isExtensionDevHost && this._environmentService.debugExtensionHost.debugId === event.sessionId) {
this._nativeHostService.closeWindow();
}
}));

//cc @isidorn

@bpasero
Copy link
Member

bpasero commented Aug 12, 2021

Ah and it seems like also this one:

public _onExtensionHostExit(code: number): void {
// Dispose everything associated with the extension host
this.stopExtensionHosts();
if (this._isExtensionDevTestFromCli) {
// When CLI testing make sure to exit with proper exit code
this._nativeHostService.exit(code);
} else {
// Expected development extension termination: When the extension host goes down we also shutdown the window
this._nativeHostService.closeWindow();
}
}

@bpasero
Copy link
Member

bpasero commented Aug 12, 2021

The latter seems the one that works here, the former seems to be used only in remote extension host scenarios.

@weinand
Copy link
Contributor Author

weinand commented Aug 12, 2021

When pressing the Stop button VS Code sends a DAP "disconnect" request to js-debug which in turn terminates the node process (EH). Some workbench code then gets a signal that the node.js child process has died. If this happens as part of a "reload command", a new EH is started and the corresponding window is not closed. Otherwise the window is closed.

@isidorn isidorn removed info-needed Issue requires more information from poster *duplicate Issue identified as a duplicate of another issue(s) labels Aug 12, 2021
@isidorn isidorn added this to the August 2021 milestone Aug 12, 2021
@isidorn
Copy link
Contributor

isidorn commented Aug 12, 2021

Thanks. So for me it seems like js-debug is not able to terminate the EH.
I can always reproduce this with VS Code Insiders with my user data dir. It is 800mb, I have shared it with you via my OneDrive, so please try to download it and repro.
With a fresh user data dir I can not reproduce this.

@connor4312 could you double check from the js-debug side if the extension is successful in shutting down the EH. Or if the process is left lying around?

fyi @alexdima @roblourens

@bpasero
Copy link
Member

bpasero commented Aug 12, 2021

I was not able to reproduce even with your user data folder, so I wonder if it is the associated data specifically for the workspace that is being debugged?

@Jason3S
Copy link

Jason3S commented Aug 12, 2021

It happens to me after I have done a reload of the debug session.

  1. Launch debugger
  2. Make a change to the code and build.
  3. Reload the debugger
  4. Repeat 2
  5. Stop debugging
  6. Notice the process does not stop.

Note: I'm using Mac OS 11.5

@weinand
Copy link
Contributor Author

weinand commented Aug 18, 2021

@connor4312 above Isi said:

.... So for me it seems like js-debug is not able to terminate the EH.

Could you please check in what situations this could happen?

@connor4312
Copy link
Member

Sorry I missed this notification. I don't believe js-debug ever terminates the extension host itself; that is normally done by core. Though I could always add code to do so...

@isidorn
Copy link
Contributor

isidorn commented Aug 23, 2021

@connor4312 I could not find the code in core that terminates the EH, I thought it was being done by the js-debug.
Could you maybe try to add code for that and than I can try to repro this issue with js-debug insiders to see if it is fixed?

@connor4312
Copy link
Member

Added and it seems to work for me. Mark verified if it does for you too, please 🙂

@connor4312 connor4312 added the bug Issue identified by VS Code Team member as probable bug label Aug 23, 2021
@weinand
Copy link
Contributor Author

weinand commented Aug 23, 2021

@connor4312 Yes, VS Code core does not do anything special when debug's stop button is pressed for extension debugging. So the Stop button just triggers a regular DAP "disconnect" protocol sequence.
And js-debug needs to terminate the debuggee because EH debugging starts with a "launch" (and the fact that there are subsequent "attach" requests should not change that).

@isidorn
Copy link
Contributor

isidorn commented Aug 23, 2021

I have verified that this indeed fixes the issue on my machine with the js-debug-nightly.
@connor4312 thanks a lot 👏

@isidorn isidorn added the verified Verification succeeded label Aug 23, 2021
@connor4312
Copy link
Member

Interesting. No idea how this was working before 😛

@weinand
Copy link
Contributor Author

weinand commented Aug 23, 2021

Good question - I do not have an explanation either...

BTW, does js-debug's extension debugging supports DAP's "terminate" request? In that case VS Code will send a "terminate" on first press of the Stop button. Could you please check with Rob what was done in node-debug2.

@isidorn isidorn added the on-release-notes Issue/pull request mentioned in release notes label Aug 27, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 7, 2021
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 on-release-notes Issue/pull request mentioned in release notes verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants
@bpasero @weinand @isidorn @connor4312 @Jason3S and others