-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Mechanism to abort the debug launch without showing launch.json #54213
Comments
Just ran into this today. After the PowerShell extension is activated, it takes about 5-8 seconds for the PowerShell Editor Services (lang/debug server) to finish starting up. While that is happening it isn't a good time to start debugging. ATM we have a NullReferenceException that occurs in PSES because it is still initializing. We could certainly fix the NullReferenceEx in PSES but I'm afraid this might be the tip of the iceberg in this case. So I've put code in BTW if there's a better way to prevent debugging until the extension is ready, please let me know. |
Fix #1433 One minor issue is that if you abort (return null|undefined) from resolveDebugConfiguration, VSCode "helpfully" opens your launch.json file for you. Actually, that is quite annoying. I found an issue and on this and voted it up - microsoft/vscode#54213 Also fix logic for "attach" error. We only need to test if OS != Windows. If on Windows, PS Core supports attach. And tweaked the error message wording to make more clear. If the user attempts to start a dgb or "run with out debugging" session before PSES is running, a NullRefEx occurs in PSES. Ideally, we would wait in the resolveDebugConfiguration method for PSES to finish initializing with a max wait time of say 10 seconds. Unfortunately, "sleep" in a loop in JavaScript is not so easy. AFAIT requires a significant rewrite of the method using setTimeout(). Not sure it is worth it, unless someone more knowledgable in JS can find an easy way to do the poll (for sessionstatus)/sleep loop. BTW there is probably a fix we need to make in PSES to check if SynchronizationContext is not null before we try to use it.
…1436) Fix #1433 One minor issue is that if you abort (return null|undefined) from resolveDebugConfiguration, VSCode "helpfully" opens your launch.json file for you. Actually, that is quite annoying. I found an issue and on this and voted it up - microsoft/vscode#54213 Also fix logic for "attach" error. We only need to test if OS != Windows. If on Windows, PS Core supports attach. And tweaked the error message wording to make more clear. If the user attempts to start a dgb or "run with out debugging" session before PSES is running, a NullRefEx occurs in PSES. Ideally, we would wait in the resolveDebugConfiguration method for PSES to finish initializing with a max wait time of say 10 seconds. Unfortunately, "sleep" in a loop in JavaScript is not so easy. AFAIT requires a significant rewrite of the method using setTimeout(). Not sure it is worth it, unless someone more knowledgable in JS can find an easy way to do the poll (for sessionstatus)/sleep loop. BTW there is probably a fix we need to make in PSES to check if SynchronizationContext is not null before we try to use it.
I've fixed this issue by adding the following line to the comment for
With this it is now possible to control what happens when aborting resolveDebugConfiguration(folder: WorkspaceFolder | undefined, config: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration> {
return vscode.window.showErrorMessage(`Program missing in debug configuration`, { modal: true }, `Open 'launch.json'`).then(result => {
if (result && result.indexOf('Open') >= 0) {
return null; // opens launch.json
}
return undefined; // aborts debugging silently
});
} |
@weinand I like the new behavior, it works well for the workspace with launch.json file, but there may be a potential break change for the workspace without launch.json. It's better to keep the debugger owners for awareness. In current VS Code 1.27.1, when the user clicks F5 in the workspace without launch.json file, VS Code will invoke In the insider with your new change, the debugger extension must return |
@testforstephen thanks for raising your concern. @isidorn let's discuss. We might want to flip the "null" and "undefined". |
We've concluded that the fix is good and @isidorn will make debug adapter authors aware of the change. |
@DanTup I know you are depending on this mechanism so please be aware of the change we are making in the new vscode release. |
@isidorn Great, thanks! I can remove some crufty code with this (where we return a debug config that has a |
Tested it and it works great for me, closes #51069 too. Thanks! |
@DanTup thanks for testing, adding verified label |
In the September drop of VSCode this fixes the issue with VSCode opening launch.json in this case. Technically just returning nothing works but better to be explicit in this case I think. microsoft/vscode#54213 (comment)
…ted (#1548) In the September drop of VSCode this fixes the issue with VSCode opening launch.json in this case. Technically just returning nothing works but better to be explicit in this case I think. microsoft/vscode#54213 (comment)
return null to trigger VS Code to open a configuration file microsoft/vscode#54213
return null to trigger VS Code to open a configuration file microsoft/vscode#54213
…pen a configuration file microsoft/vscode#54213
…pen a configuration file microsoft/vscode#54213
…pen a configuration file microsoft/vscode#54213
We have today the with this method:
interface DebugConfigurationProvider {
resolveDebugConfiguration(...)
So far is flexible enough except in scenarios where we want our provider to abort the debug launch without having vscode to think that the configuration is wrong or missing something important. In the 'live share' scenario we are launching remote debug sessions by allowing vscode to display them but not necessary to launch a remote debug session that will eventually arrive later. We want the resolveDebugConfiguartion to allow this by return a blessed debug configuartion or probably best by throwing a DebugConfiguartionCancelledException() that vscode would handle nicely.
The text was updated successfully, but these errors were encountered: