fix(daemon): propagate startup failure reason to user (GH#863)
When daemon fails to start due to legacy database or fingerprint validation, the error was only logged to daemon.log. Users saw "Daemon took too long" with no hint about the actual problem. Changes: - Write validation errors to .beads/daemon-error file before daemon exits - Check for daemon-error file in autostart and display contents on timeout - Elevate legacy database check in bd doctor from warning to error Now when daemon fails due to legacy database, users see: "LEGACY DATABASE DETECTED! ... Run 'bd migrate --update-repo-id' to add fingerprint" Instead of just "Daemon took too long to start". 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -340,6 +340,17 @@ func startDaemonProcess(socketPath string) bool {
|
||||
|
||||
recordDaemonStartFailure()
|
||||
debugLog("daemon socket not ready after 5 seconds")
|
||||
|
||||
// Check for daemon-error file which contains the actual failure reason
|
||||
beadsDir := filepath.Dir(dbPath)
|
||||
errFile := filepath.Join(beadsDir, "daemon-error")
|
||||
if errContent, err := os.ReadFile(errFile); err == nil && len(errContent) > 0 {
|
||||
// Show the actual error from the daemon
|
||||
fmt.Fprintf(os.Stderr, "%s Daemon failed to start:\n", ui.RenderWarn("Warning:"))
|
||||
fmt.Fprintf(os.Stderr, "%s\n", string(errContent))
|
||||
return false
|
||||
}
|
||||
|
||||
// Emit visible warning so user understands why command was slow
|
||||
fmt.Fprintf(os.Stderr, "%s Daemon took too long to start (>5s). Running in direct mode.\n", ui.RenderWarn("Warning:"))
|
||||
fmt.Fprintf(os.Stderr, " %s Run 'bd doctor' to diagnose daemon issues\n", ui.RenderMuted("Hint:"))
|
||||
|
||||
Reference in New Issue
Block a user