mirror of
https://github.com/Dasemu/remote-mcp-manager.git
synced 2026-11-26 15:26:27 +00:00
- proxy: inactivity timeouts and a cap on concurrent requests (503 beyond it) - docker: cache/coalesce container IP lookups and time out inspect calls - sessions: SQLite-backed store instead of the leaking MemoryStore - memory guard: exit when heap+external passes MANAGER_MEMORY_LIMIT_MB so the restart policy replaces the process before the host swaps - builds: serialize them and time out hung git/nixpacks processes - redeploy with rebuild no longer deploys the old image after a failed build - /health reports memory and in-flight proxy requests; handle SIGTERM Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { isOverLimit, startMemoryGuard } from "./memoryGuard.js";
|
|
|
|
const MB = 1024 * 1024;
|
|
|
|
describe("isOverLimit", () => {
|
|
it("counts heap + external against the limit", () => {
|
|
expect(isOverLimit({ heapUsed: 300 * MB, external: 250 * MB }, 512)).toBe(true);
|
|
expect(isOverLimit({ heapUsed: 300 * MB, external: 100 * MB }, 512)).toBe(false);
|
|
});
|
|
|
|
it("is disabled when the limit is 0", () => {
|
|
expect(isOverLimit({ heapUsed: 9999 * MB, external: 0 }, 0)).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("startMemoryGuard", () => {
|
|
it("fires onExceeded exactly once after the limit is passed", async () => {
|
|
const onExceeded = vi.fn();
|
|
const timer = startMemoryGuard({
|
|
limitMb: 100,
|
|
intervalMs: 5,
|
|
sample: () => ({ heapUsed: 200 * MB, external: 0 }),
|
|
onExceeded,
|
|
});
|
|
await new Promise((r) => setTimeout(r, 40));
|
|
clearInterval(timer);
|
|
expect(onExceeded).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("does not start when disabled", () => {
|
|
expect(startMemoryGuard({ limitMb: 0, onExceeded: () => {} })).toBeUndefined();
|
|
});
|
|
});
|