Skip to content

Commit 1ab4207

Browse files
committed
Avoid timeouts in Electron shutdown
Only reliably reproducible when running the unit tests on Windows, but likely affects other cases too.
1 parent 2ad4df7 commit 1ab4207

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/interceptors/electron.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,12 @@ export class ElectronInterceptor implements Interceptor {
185185

186186
if (!shutdown) {
187187
// Didn't shutdown yet? Inject a hard exit.
188-
await debugClient.Runtime.evaluate({
189-
expression: 'process.exit(0)'
190-
}).catch(() => {}) // Ignore errors (there's an inherent race here)
188+
await Promise.race([
189+
debugClient.Runtime.evaluate({
190+
expression: 'process.exit(0)'
191+
}).catch(() => {}), // Ignore errors (there's an inherent race here)
192+
disconnectPromise // If we disconnect, evaluate can time out
193+
]);
191194
};
192195
})
193196
);

0 commit comments

Comments
 (0)