From 626713d4854ee4672c5f0be621746ba301a5b471 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 27 Oct 2023 11:41:16 +0200 Subject: [PATCH] Forcefully kill extension host processes if they still exist (fixes #194477) --- .../electron-main/extensionHostStarter.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/vs/platform/extensions/electron-main/extensionHostStarter.ts b/src/vs/platform/extensions/electron-main/extensionHostStarter.ts index 2d5a39fa1daa0..19fcb4dd70a66 100644 --- a/src/vs/platform/extensions/electron-main/extensionHostStarter.ts +++ b/src/vs/platform/extensions/electron-main/extensionHostStarter.ts @@ -78,6 +78,21 @@ export class ExtensionHostStarter implements IDisposable, IExtensionHostStarter extHost.dispose(); this._extHosts.delete(id); }); + + // See https://github.com/microsoft/vscode/issues/194477 + // We have observed that sometimes the process sends an exit + // event, but does not really exit and is stuck in an endless + // loop. In these cases we kill the process forcefully after + // a certain timeout. + setTimeout(() => { + try { + process.kill(pid, 0); // will throw if the process doesn't exist anymore. + this._logService.error(`Extension host with pid ${pid} still exists, forcefully killing it...`); + process.kill(pid); + } catch (er) { + // ignore, as the process is already gone + } + }, 1000); }); return { id }; }