fix: stop orphaned opencode processes on desktop quit

Exit the desktop app without waiting on background cleanup
Kill managed OpenCode by process group with a port fallback
Make OpenCode shutdown reuse the active shutdown promise
This commit is contained in:
Bohdan Triapitsyn
2026-06-03 14:51:17 +03:00
parent a649ba8df4
commit 2b098d36f5
5 changed files with 159 additions and 50 deletions
@@ -29,7 +29,9 @@ export const createGracefulShutdownRuntime = (dependencies) => {
tunnelAuthController,
} = dependencies;
const gracefulShutdown = async (options = {}) => {
let shutdownPromise = null;
const runShutdown = async (options = {}) => {
if (getIsShuttingDown()) return;
setIsShuttingDown(true);
@@ -133,6 +135,12 @@ export const createGracefulShutdownRuntime = (dependencies) => {
}
};
const gracefulShutdown = (options = {}) => {
if (shutdownPromise) return shutdownPromise;
shutdownPromise = runShutdown(options);
return shutdownPromise;
};
return {
gracefulShutdown,
};