fix: add error handling for unhandled promise rejections (#992)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
TÂCHES 2026-03-17 17:06:17 -06:00 committed by GitHub
parent 058f682f67
commit 6b3572c858
4 changed files with 13 additions and 3 deletions

View file

@ -125,6 +125,10 @@ export class BgManagerOverlay {
restartProcess(proc.id).then(() => {
this.invalidate();
this.tui.requestRender();
}).catch((err) => {
if (process.env.GSD_DEBUG) console.error('[bg-shell] restart failed:', err);
this.invalidate();
this.tui.requestRender();
});
}
return;

View file

@ -37,7 +37,9 @@ export async function closeoutUnit(
const { buildMemoryLLMCall, extractMemoriesFromUnit } = await import('./memory-extractor.js');
const llmCallFn = buildMemoryLLMCall(ctx);
if (llmCallFn) {
extractMemoriesFromUnit(activityFile, unitType, unitId, llmCallFn).catch(() => {});
extractMemoriesFromUnit(activityFile, unitType, unitId, llmCallFn).catch((err) => {
if (process.env.GSD_DEBUG) console.error(`[gsd] memory extraction failed for ${unitType}/${unitId}:`, err);
});
}
} catch { /* non-fatal */ }
}

View file

@ -716,7 +716,9 @@ export async function saveFile(path: string, content: string): Promise<void> {
await fs.rename(tmpPath, path);
} catch (err) {
// Clean up orphaned temp file on rename failure
await fs.unlink(tmpPath).catch(() => {});
await fs.unlink(tmpPath).catch((unlinkErr) => {
if (process.env.GSD_DEBUG) console.error(`[gsd] temp file cleanup failed for ${tmpPath}:`, unlinkErr);
});
throw err;
}
}

View file

@ -30,6 +30,7 @@ import { detectProjectState } from "./detection.js";
import { showProjectInit, offerMigration } from "./init-wizard.js";
import { showConfirm } from "../shared/confirm-ui.js";
import { loadQueueOrder, sortByQueueOrder, saveQueueOrder } from "./queue-order.js";
import { debugLog } from "./debug-logger.js";
// ─── Commit Instruction Helpers ──────────────────────────────────────────────
@ -148,8 +149,9 @@ export function checkAutoStartAfterDiscuss(): boolean {
pendingAutoStart = null;
startAuto(ctx, pi, basePath, false, { step }).catch((err) => {
ctx.ui.notify(`Auto-start failed: ${err instanceof Error ? err.message : String(err)}`, "warning");
ctx.ui.notify(`Auto-start failed: ${err instanceof Error ? err.message : String(err)}`, "error");
if (process.env.GSD_DEBUG) console.error('[gsd] auto start error:', err);
debugLog("auto-start-failed", { error: err instanceof Error ? err.message : String(err) });
});
return true;
}