From ac46ca2a5e5aaab3f01cffec46d3e2ac96519f1f Mon Sep 17 00:00:00 2001 From: Andre Weinand Date: Fri, 8 Mar 2019 16:41:06 +0100 Subject: [PATCH] make caching more robust; fixes #69534 --- .../electron-browser/mainThreadDebugService.ts | 8 +++++++- src/vs/workbench/api/node/extHost.protocol.ts | 1 + src/vs/workbench/api/node/extHostDebugService.ts | 16 ++++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts index fe7631d0a0e..f61a76d2404 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts @@ -285,6 +285,12 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb // dto helpers + public $sessionCached(sessionID: string) { + // remember that the EH has cached the session and we do not have to send it again + this._sessions.add(sessionID); + } + + getSessionDto(session: undefined): undefined; getSessionDto(session: IDebugSession): IDebugSessionDto; getSessionDto(session: IDebugSession | undefined): IDebugSessionDto | undefined; @@ -294,7 +300,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb if (this._sessions.has(sessionID)) { return sessionID; } else { - this._sessions.add(sessionID); + // this._sessions.add(sessionID); // #69534: see $sessionCached above return { id: sessionID, type: session.configuration.type, diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 2c21e157732..1f1c31c72cc 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -636,6 +636,7 @@ export type DebugSessionUUID = string; export interface MainThreadDebugServiceShape extends IDisposable { $registerDebugTypes(debugTypes: string[]): void; + $sessionCached(sessionID: string): void; $acceptDAMessage(handle: number, message: DebugProtocol.ProtocolMessage): void; $acceptDAError(handle: number, name: string, message: string, stack: string): void; $acceptDAExit(handle: number, code: number, signal: string): void; diff --git a/src/vs/workbench/api/node/extHostDebugService.ts b/src/vs/workbench/api/node/extHostDebugService.ts index 880a550dab4..1ffffaaa231 100644 --- a/src/vs/workbench/api/node/extHostDebugService.ts +++ b/src/vs/workbench/api/node/extHostDebugService.ts @@ -794,19 +794,23 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { if (typeof dto === 'string') { return this._debugSessions.get(dto); } else { - const folder = await this.getFolder(dto.folderUri); - const debugSession = new ExtHostDebugSession(this._debugServiceProxy, dto.id, dto.type, dto.name, folder, dto.configuration); - this._debugSessions.set(debugSession.id, debugSession); - return debugSession; + let ds = this._debugSessions.get(dto.id); + if (!ds) { + const folder = await this.getFolder(dto.folderUri); + ds = new ExtHostDebugSession(this._debugServiceProxy, dto.id, dto.type, dto.name, folder, dto.configuration); + this._debugSessions.set(ds.id, ds); + this._debugServiceProxy.$sessionCached(ds.id); + } + return ds; } } return undefined; } - private async getFolder(_folderUri: UriComponents | undefined): Promise { + private getFolder(_folderUri: UriComponents | undefined): Promise { if (_folderUri) { const folderURI = URI.revive(_folderUri); - return await this._workspaceService.resolveWorkspaceFolder(folderURI); + return this._workspaceService.resolveWorkspaceFolder(folderURI); } return undefined; } -- GitLab