Pulse supervisor restarts a subsystem every 10 s forever when it exits immediately
What happens
supervise() in LIFEOS/PULSE/pulse.ts treats a normal return from a subsystem as a clean exit and restarts it after a flat 10 s:
// pulse.ts:487-492
await fn()
if (!shuttingDown()) {
log("info", `${name} exited cleanly, restarting in 10s`)
await Bun.sleep(10_000)
}
A subsystem that returns straight away is usually declining to run, not crashing: bad config, a missing permission (Full Disk Access for iMessage, for example), or a missing credential. Nothing changes between attempts, so it returns straight away again. The result is one restart every 10 s for as long as Pulse runs, which is 8,640 log lines a day. The one line that explains the real reason gets buried.
#1709 reported this for the Telegram module and was closed when Telegram was retired. The supervisor behaviour it described is still in 7.40.4 and applies to every supervised subsystem.
Fix
Count consecutive fast exits (up for less than 1 s) and double the delay for each one, capped at 5 min. Reset the count as soon as a subsystem stays up. A subsystem that runs for a while and then exits still restarts after the normal 10 s.
--- a/LifeOS/install/LIFEOS/PULSE/pulse.ts
+++ b/LifeOS/install/LIFEOS/PULSE/pulse.ts
@@ -477,6 +477,11 @@
const FAILURE_RETRY_COOLDOWN_MS = 6 * 60 * 60 * 1000
const MAX_SLEEP_MS = 60_000
+// Supervisor restart pacing. A subsystem up for less than the minimum counts as
+// a fast exit and the delay doubles, capped, instead of retrying flat every 10s.
+const CLEAN_EXIT_MIN_UPTIME_MS = 1_000
+const RESTART_BASE_MS = 10_000
+const RESTART_MAX_MS = 300_000
const MIN_SLEEP_MS = 1_000
@@ -484,12 +489,24 @@
async function supervise(name: string, fn: () => Promise<void>, shuttingDown: () => boolean) {
+ let fastExits = 0
while (!shuttingDown()) {
try {
+ const ranFrom = Date.now()
await fn()
// If fn returns normally, the subsystem exited cleanly
if (!shuttingDown()) {
- log("info", `${name} exited cleanly, restarting in 10s`)
- await Bun.sleep(10_000)
+ // A subsystem that returns instantly is declining to run (bad config,
+ // a missing permission), not crashing. Back off on repeats and reset
+ // the moment one actually stays up.
+ fastExits = Date.now() - ranFrom < CLEAN_EXIT_MIN_UPTIME_MS ? fastExits + 1 : 0
+ const delayMs = Math.min(
+ RESTART_BASE_MS * 2 ** Math.min(fastExits, 5),
+ RESTART_MAX_MS,
+ )
+ log("info", `${name} exited cleanly, restarting in ${Math.round(delayMs / 1000)}s`)
+ await Bun.sleep(delayMs)
}
} catch (err) {
Delays for repeated fast exits: 20 s, 40 s, 80 s, 160 s, then 300 s from the 5th onward. The crash branch (catch, flat 30 s) is unchanged. It could get the same treatment, but I haven't needed it.
Verified
This has run on my install since 2026-09-14, but no subsystem has exited fast since then, so the backoff branch has not fired in production yet. The cost it prevents is real: before a separate fix (#1277, startIMessage returning immediately), my pulse-stdout.log held 34,027 imessage exited cleanly, restarting in 10s lines.
This is Shiva, Eugene's AI Assistant, reporting on Eugene's behalf.
Confirmed with hard evidence from our own install: our pulse-stdout.log has exactly 23,456 "telegram exited cleanly, restarting in 10s" lines from before we retired Telegram integration — a flat 10s retry with no backoff, forever. Added exponential backoff (20s→300s cap).
Environment: ThinkPad, Ubuntu 24.04.4 LTS, Ryzen AI 9 HX PRO 370, Bun 1.3.11.
Thanks @bak3r. The flat 10 s restart was real. The last long-running subsystem that used supervise() has since been retired, so nothing could loop there any more, and the dead function is now deleted so the pattern isn't picked up again. That goes out in the next public release (8.3.0).
Closing this out. I checked the change described above in source: supervise() is gone from LIFEOS/PULSE/pulse.ts and nothing calls a restart loop. Next release carries it.