From d2339b8d4446e732fbb95d75dab12964d9514df8 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 5 Mar 2026 13:03:35 -0800 Subject: [PATCH] fix update spawn error handling and reset flag --- src/server/api/system.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/server/api/system.ts b/src/server/api/system.ts index 0d50119..5a70175 100644 --- a/src/server/api/system.ts +++ b/src/server/api/system.ts @@ -304,9 +304,16 @@ router.get('/update', async c => { router.post('/update', c => { if (isUpdating) return c.json({ ok: false, error: 'update already in progress' }, 409) isUpdating = true - const script = join(projectRoot, 'install/install.sh') - Bun.spawn(['bash', script], { cwd: projectRoot, stdout: 'ignore', stderr: 'ignore' }) - return c.json({ ok: true }) + try { + const script = join(projectRoot, 'install/install.sh') + const proc = Bun.spawn(['bash', script], { cwd: projectRoot, stdout: 'ignore', stderr: 'ignore' }) + proc.exited.then(code => { if (code !== 0) isUpdating = false }) + .catch(() => { isUpdating = false }) + return c.json({ ok: true }) + } catch { + isUpdating = false + return c.json({ ok: false, error: 'failed to start update' }, 500) + } }) export default router