From 25e5af99d7fba23bada74ef6c195f082bc9665a0 Mon Sep 17 00:00:00 2001 From: clagentic <10177887+akuehner@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:59:01 -0400 Subject: [PATCH] fix(daemon): guard bootstrap config write against disk-full crash Codex review finding: writeFileSync on fresh-install bootstrap was unprotected. Disk-full or other I/O errors would throw uncaught and crash the daemon instead of logging a clear error and exiting cleanly. Co-Authored-By: Claude Sonnet 4.6 --- lib/daemon.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/daemon.js b/lib/daemon.js index 3a8c7c4..da3d41f 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -49,7 +49,12 @@ try { var _isDev = !!(process.env.CLAGENTIC_DEV || process.env.CLAY_DEV); config = { port: _isDev ? 2635 : 2633, projects: [], mode: "single", setupCompleted: false }; // Persist so subsequent reads succeed. - fs.writeFileSync(configFile, JSON.stringify(config, null, 2), { mode: 0o600 }); + try { + fs.writeFileSync(configFile, JSON.stringify(config, null, 2), { mode: 0o600 }); + } catch (writeErr) { + console.error("[daemon] Failed to persist bootstrap config:", writeErr.message); + process.exit(1); + } } else { console.error("[daemon] Failed to read config:", e.message); process.exit(1);