Skip to content

Commit 5dc5127

Browse files
committed
fix(server): re-check token before waitSpawned declares child death
A token-print-and-exit server can flush its banner after the loop's top-of-loop token check; the reaper's fast liveness signal then failed Connect even though the token was captured. The token wins.
1 parent a17914d commit 5dc5127

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎internal/server/server.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,14 @@ func waitSpawned(baseURL string, scan *tokenScanWriter, alive func() bool, timeo
462462
} else if !readyAt.IsZero() {
463463
readyAt = time.Time{} // flapping: restart the grace clock
464464
}
465+
// Re-check the token before declaring death: a fast-exiting
466+
// (or token-print-and-exit) server can flush its banner after
467+
// this iteration's top-of-loop check — the token wins.
465468
if alive != nil && !alive() {
466-
return fmt.Errorf("odek serve exited before becoming ready%w", stderrTail(scan))
469+
if scan == nil || scan.Token() == "" {
470+
return fmt.Errorf("odek serve exited before becoming ready%w", stderrTail(scan))
471+
}
472+
return nil
467473
}
468474
time.Sleep(150 * time.Millisecond)
469475
}

0 commit comments

Comments
 (0)