fix: self-heal in-flight counts by pruning stale request ids
On a long-lived SSE connection a missed remove leaves a stale request id in the tracker forever; llama-swap only sends a fresh snapshot on connect, so counts drifted up and stayed stuck. The tracker now timestamps each request id (upserts refresh it) and prunes ids not updated within 120s, on every inflight event and on a 30s runtime interval. Removes also accept numeric ids defensively.
This commit is contained in:
@@ -67,6 +67,15 @@ test("decodeEvent parses an inflight remove with a bare id", () => {
|
||||
assert.deepEqual(ev, { type: "inflight", operation: "remove", id: "817" });
|
||||
});
|
||||
|
||||
test("decodeEvent accepts a numeric id on remove", () => {
|
||||
const msg: SseMessage = {
|
||||
event: "message",
|
||||
data: JSON.stringify({ type: "inflight", data: JSON.stringify({ operation: "remove", id: 820 }) }),
|
||||
};
|
||||
const ev = decodeEvent(msg);
|
||||
assert.deepEqual(ev, { type: "inflight", operation: "remove", id: "820" });
|
||||
});
|
||||
|
||||
test("decodeEvent parses modelStatus", () => {
|
||||
const msg: SseMessage = {
|
||||
event: "message",
|
||||
|
||||
Reference in New Issue
Block a user