VSCode only waits for 1 second on disconnect
- VSCode Version: 1.3.1
- OS Version: Windows/Mac
Steps to Reproduce: This issue can be reproduced with the sample and repro steps provided by @jeffschwMSFT in issue https://github.com/OmniSharp/omnisharp-vscode/issues/352
Refer: https://github.com/OmniSharp/omnisharp-vscode/issues/582 for the related bug in omnisharp-vscode.
Issue: VSCode only waits for 1 second for the debugger to disconnect. When there is a long running operation on debugger (such as expanding a long array on watch window) the debugger is still holding on to the dll/pdbs. VSCode spawns build tasks, which eventually fails because of file locks and resulting project in a bad state (The files are zero sized on mac, missing dlls on windows etc).
code: workbench/parts/debug/node/rawDebugSession.ts function: disconnect
Potential fixes
- Wait for infinite amount of time for the debugger to exit.
- Provide a different event which can forcefully terminate the debugger on a certain timeout.
As Andre pointed out the analysis in your issue is not correct, the 1000ms timeout is not related due to that I am closing the issue. Once we find more details and if there is something lacking on the vscode side we can create one that is more precise.
After a bit of debugging and adding some logs to v8protocol.ts, I figure VSCode does not wait for disconnect response from the debugger. This results in file locking issues. Refer: OmniSharp/omnisharp-vscode#582 for the related bug in omnisharp-vscode.
In the logs below are, command request and response entries. When application is terminated or restarted, a 'disconnect' request is sent but VSCode does not wait for a response. In the case of an application restart, it 'disconnect' is requested and immediately VSCode spins up build tasks would fail because debugger hasn't released the dll/pdb.
Application run to completion, has disconnect response.
command request: initialize command response: initialize command request: launch command request: setBreakpoints command response: launch command response: setBreakpoints command request: setExceptionBreakpoints command response: setExceptionBreakpoints command request: configurationDone command response: configurationDone command request: threads command response: threads command request: threads command response: threads command request: stackTrace command response: stackTrace command request: scopes command request: evaluate command request: continue command response: scopes command request: variables command response: evaluate command response: continue command response: variables command request: disconnect command response: disconnect
Application terminated, does not have disconnect response.
command request: initialize command response: initialize command request: launch command request: setBreakpoints command response: launch command response: setBreakpoints command request: setExceptionBreakpoints command response: setExceptionBreakpoints command request: configurationDone command response: configurationDone command request: threads command response: threads command request: threads command response: threads command request: stackTrace command response: stackTrace command request: scopes command request: evaluate command request: disconnect
Application restarted when debugger was expanding variables. Does not have disconnect response.
command request: initialize command response: initialize command request: launch command request: setBreakpoints command response: launch command response: setBreakpoints command request: setExceptionBreakpoints command response: setExceptionBreakpoints command request: configurationDone command response: configurationDone command request: threads command response: threads command request: threads command response: threads command request: stackTrace command response: stackTrace command request: scopes command request: evaluate command request: disconnect command request: evaluate command request: initialize command response: initialize command request: launch command request: setBreakpoints command response: launch command response: setBreakpoints command request: setExceptionBreakpoints command response: setExceptionBreakpoints command request: configurationDone command response: configurationDone command request: threads command response: threads command request: threads command response: threads command request: stackTrace command response: stackTrace command request: scopes command request: evaluate command response: scopes command request: variables command response: evaluate command response: variables command request: variables command response: variables command request: variables command request: disconnect command request: initialize command response: initialize command request: launch command request: setBreakpoints command response: launch command response: setBreakpoints command request: setExceptionBreakpoints command response: setExceptionBreakpoints command request: configurationDone command response: configurationDone command request: threads command response: threads command request: threads command response: threads command request: stackTrace command response: stackTrace command request: scopes command request: evaluate command response: scopes command request: variables command response: evaluate command response: variables
Reopening issue to further investigate
@rajkumar42 thank you for providing more details. The issue was that we accidently also canceled the 'disconnect' promise on 'disconnect'. This is no longer the case and vscode will wait for the 'disconnect' response an infinite amount of time. If the debugger is in a bad state and can not disconnect the user can always click on the stop button again and that will force vscode to shut down the debug adapter.
@isidorn Excellent! Thanks.
Thanks for the quick turnaround @isidorn !!