mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-27 04:39:30 +00:00
15 lines
693 B
TypeScript
15 lines
693 B
TypeScript
// Process-lifetime wait primitive for CLI paths that intentionally never return.
|
|
export function waitForever() {
|
|
// Keep the event loop alive with a ref'd interval. A pending Promise is not
|
|
// an active handle on its own, so without the interval, Node exits the
|
|
// process with code 13 ("unsettled top-level await") as soon as nothing
|
|
// else is keeping the loop open — defeating the "wait forever" contract.
|
|
// The handle is intentionally not retained: there is no caller-visible way
|
|
// to stop a "forever" wait, and the interval lives for the lifetime of the
|
|
// process.
|
|
setInterval(() => {}, 1_000_000);
|
|
return new Promise<void>(() => {
|
|
/* never resolve */
|
|
});
|
|
}
|