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] Wait for debugger capabilities initialization before breakpoint update #11607

Merged
merged 2 commits into from
Dec 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/debug/src/browser/debug-session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export enum DebugState {

// FIXME: make injectable to allow easily inject services
export class DebugSession implements CompositeTreeElement {
private onCapabilitiesConfiguredEmitter = new Emitter<void>();
private readonly onCapabilitiesConfigured = this.onCapabilitiesConfiguredEmitter.event;

protected readonly onDidChangeEmitter = new Emitter<void>();
readonly onDidChange: Event<void> = this.onDidChangeEmitter.event;
protected fireDidChange(): void {
Expand Down Expand Up @@ -507,6 +510,18 @@ export class DebugSession implements CompositeTreeElement {

protected updateCapabilities(capabilities: DebugProtocol.Capabilities): void {
Object.assign(this._capabilities, capabilities);
this.onCapabilitiesConfiguredEmitter.fire(undefined);
}

private waitUntilCapabilitiesConfigured(): Promise<void> {
return new Promise((resolve, reject) => {
if (Object.keys(this._capabilities).length !== 0) {
resolve();
}

this.onCapabilitiesConfigured(resolve);
setTimeout(reject, 300);
});
}

protected readonly _breakpoints = new Map<string, DebugBreakpoint[]>();
Expand Down Expand Up @@ -634,6 +649,7 @@ export class DebugSession implements CompositeTreeElement {
return;
}
const { uri, sourceModified } = options;
await this.waitUntilCapabilitiesConfigured();
for (const affectedUri of this.getAffectedUris(uri)) {
if (affectedUri.toString() === BreakpointManager.EXCEPTION_URI.toString()) {
await this.sendExceptionBreakpoints();
Expand Down