mirror of
https://github.com/Dasemu/remote-mcp-manager.git
synced 2026-11-26 15:26:27 +00:00
fix: bound memory and sockets in the manager to prevent host-wide OOM
- 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>
This commit is contained in:
1 parent
05ad174f90
commit
eb24e21df7
14 files changed
+371
-12
No files matched your search
@@ -0,0 +1,34 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user