Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eso-refresher-keepalive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@smooai/config': patch
---

SMOODEV-1527: Fix the eso-refresher exiting immediately after its initial mint (it `unref()`'d the interval timer, and a pending `await new Promise(() => {})` doesn't hold Node's event loop open — so the process exited 0 → CrashLoopBackOff). The production interval now keeps the daemon alive; tests inject their own scheduler so they're unaffected.
8 changes: 6 additions & 2 deletions src/eso-refresher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,12 @@ export interface EsoRefresherHandle {

function defaultScheduler(fn: () => void, ms: number): { clear: () => void } {
const t = setInterval(fn, ms);
// Don't keep the event loop alive solely for the timer in tests/CLI teardown.
if (typeof t.unref === 'function') t.unref();
// SMOODEV-1527: do NOT unref() — the interval is what keeps the daemon's
// event loop alive. A pending `await new Promise(() => {})` in main() does
// NOT hold the loop open by itself, so unref'ing here let the process exit 0
// right after the initial mint → CrashLoopBackOff. Tests inject their own
// scheduler, so this only affects the real CLI/sidecar (where we WANT it
// to keep running). `stop()` still calls clear() for clean shutdown.
return { clear: () => clearInterval(t) };
}

Expand Down
Loading