Revert "fix: prevent orphaned gateway processes on Windows causing port conflcts and UI freeze (#570)"

This reverts commit 2dc1070213.
This commit is contained in:
paisley
2026-03-18 18:28:34 +08:00
Unverified
parent b27815b394
commit dbc9972fb8
2 changed files with 16 additions and 52 deletions

View File

@@ -459,30 +459,15 @@ if (gotTheLock) {
}
});
let gatewayCleanedUp = false;
app.on('before-quit', (event) => {
app.on('before-quit', () => {
setQuitting();
// On first before-quit, block the quit so we can await gateway cleanup.
// On Windows, fire-and-forget leaves orphaned Python/uv processes that
// hold port 18789, causing port conflicts on next launch.
if (!gatewayCleanedUp) {
gatewayCleanedUp = true;
event.preventDefault();
hostEventBus.closeAll();
hostApiServer?.close();
const stopPromise = gatewayManager.stop().catch((err) => {
logger.warn('gatewayManager.stop() error during quit:', err);
});
const timeoutPromise = new Promise<void>((resolve) => setTimeout(resolve, 5000));
void Promise.race([stopPromise, timeoutPromise]).then(() => {
app.exit(0);
});
}
hostEventBus.closeAll();
hostApiServer?.close();
// Fire-and-forget: do not await gatewayManager.stop() here.
// Awaiting inside before-quit can stall Electron's quit sequence.
void gatewayManager.stop().catch((err) => {
logger.warn('gatewayManager.stop() error during quit:', err);
});
});
}