Skip to content

Commit 98b67fa

Browse files
committed
watcher - do not dispose when shared process gone
1 parent 061a665 commit 98b67fa

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/vs/platform/sharedProcess/electron-main/sharedProcess.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ export class SharedProcess extends Disposable implements ISharedProcess {
9292
const disposables = new DisposableStore();
9393

9494
const disposeWorker = (reason: string) => {
95+
if (!this.isAlive()) {
96+
return; // the shared process is already gone, no need to dispose anything
97+
}
98+
9599
this.logService.trace(`SharedProcess: disposing worker (reason: '${reason}')`, configuration);
96100

97101
// Only once!
@@ -152,14 +156,13 @@ export class SharedProcess extends Disposable implements ISharedProcess {
152156
}
153157

154158
private send(channel: string, ...args: any[]): void {
155-
const window = this.window;
156-
if (!window || window.isDestroyed() || window.webContents.isDestroyed()) {
159+
if (!this.isAlive()) {
157160
this.logService.warn(`Sending IPC message to channel '${channel}' for shared process window that is destroyed`);
158161
return;
159162
}
160163

161164
try {
162-
window.webContents.send(channel, ...args);
165+
this.window?.webContents.send(channel, ...args);
163166
} catch (error) {
164167
this.logService.warn(`Error sending IPC message to channel '${channel}' of shared process: ${toErrorMessage(error)}`);
165168
}
@@ -305,4 +308,13 @@ export class SharedProcess extends Disposable implements ISharedProcess {
305308
isVisible(): boolean {
306309
return this.window?.isVisible() ?? false;
307310
}
311+
312+
private isAlive(): boolean {
313+
const window = this.window;
314+
if (!window) {
315+
return false;
316+
}
317+
318+
return !window.isDestroyed() && !window.webContents.isDestroyed();
319+
}
308320
}

0 commit comments

Comments
 (0)