Files
gitea-mirror/src/lib/shutdown-manager.test.ts
T
ARUNAVO RAY 4f96e7dfbf fix: survive SSE client disconnects on Bun 1.4 (#465) (#466)
On Bun 1.4 the node adapter's reader cancel closes the stream before the
request abort fires, so the abort listener's controller.close() threw
ERR_INVALID_STATE as an uncaught exception and the process shut itself
down whenever a dashboard tab disconnected. Both SSE routes now guard the
close and clear their timers on cancel too.

A shutdown forced by an uncaught exception or unhandled rejection now
exits with status 1 instead of 0, so a unit with Restart=on-failure
(the Proxmox community script) starts the service again.
2026-10-15 18:46:56 +05:30

16 lines
589 B
TypeScript

import { describe, expect, test } from "bun:test";
import { shutdownExitCode } from "./shutdown-manager";
describe("shutdownExitCode (#465)", () => {
test("a crash-driven shutdown exits non-zero so Restart=on-failure restarts the service", () => {
expect(shutdownExitCode("UNCAUGHT_EXCEPTION")).toBe(1);
expect(shutdownExitCode("UNHANDLED_REJECTION")).toBe(1);
});
test("a signal-driven stop is a clean exit", () => {
expect(shutdownExitCode("SIGTERM")).toBe(0);
expect(shutdownExitCode("SIGINT")).toBe(0);
expect(shutdownExitCode("SIGHUP")).toBe(0);
});
});