File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
src/vs/platform/sharedProcess/electron-main Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ export class SharedProcess extends Disposable implements ISharedProcess {
92
92
const disposables = new DisposableStore ( ) ;
93
93
94
94
const disposeWorker = ( reason : string ) => {
95
+ if ( ! this . isAlive ( ) ) {
96
+ return ; // the shared process is already gone, no need to dispose anything
97
+ }
98
+
95
99
this . logService . trace ( `SharedProcess: disposing worker (reason: '${ reason } ')` , configuration ) ;
96
100
97
101
// Only once!
@@ -152,14 +156,13 @@ export class SharedProcess extends Disposable implements ISharedProcess {
152
156
}
153
157
154
158
private send ( channel : string , ...args : any [ ] ) : void {
155
- const window = this . window ;
156
- if ( ! window || window . isDestroyed ( ) || window . webContents . isDestroyed ( ) ) {
159
+ if ( ! this . isAlive ( ) ) {
157
160
this . logService . warn ( `Sending IPC message to channel '${ channel } ' for shared process window that is destroyed` ) ;
158
161
return ;
159
162
}
160
163
161
164
try {
162
- window . webContents . send ( channel , ...args ) ;
165
+ this . window ? .webContents . send ( channel , ...args ) ;
163
166
} catch ( error ) {
164
167
this . logService . warn ( `Error sending IPC message to channel '${ channel } ' of shared process: ${ toErrorMessage ( error ) } ` ) ;
165
168
}
@@ -305,4 +308,13 @@ export class SharedProcess extends Disposable implements ISharedProcess {
305
308
isVisible ( ) : boolean {
306
309
return this . window ?. isVisible ( ) ?? false ;
307
310
}
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
+ }
308
320
}
You can’t perform that action at this time.
0 commit comments