PM2 max_memory SIGINT was ending the Prisma/pg pool while archive and delivery jobs still queried it, flooding "Cannot use a pool after calling end". Await idle on all loop workers before $disconnect, and raise the worker memory/kill_timeout so burst indexing does not restart every few minutes. Paperclip-Agent: David Santos (urlKey founding-engineer; id 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376) Paperclip-Issue: BIT-31189 Paperclip-Run: 61448079-9293-4b3b-989d-b5857bf058c1
21 lines
650 B
TypeScript
21 lines
650 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { waitUntil } from "../src/lib/idle.js";
|
|
|
|
describe("waitUntil", () => {
|
|
it("resolves true when the predicate is already true", async () => {
|
|
expect(await waitUntil(() => true, { timeoutMs: 100 })).toBe(true);
|
|
});
|
|
|
|
it("waits until the predicate flips", async () => {
|
|
let ready = false;
|
|
setTimeout(() => {
|
|
ready = true;
|
|
}, 30);
|
|
expect(await waitUntil(() => ready, { timeoutMs: 500, intervalMs: 10 })).toBe(true);
|
|
});
|
|
|
|
it("returns false on timeout", async () => {
|
|
expect(await waitUntil(() => false, { timeoutMs: 40, intervalMs: 10 })).toBe(false);
|
|
});
|
|
});
|