mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-20 13:52:28 +03:00
Merged. Four small, independently justified changes, each with its own regression test — naming both sides of a case-insensitive key collision, surfacing the dropped-header count to the caller instead of only to the log, one retry before a memory is left unvectorized, and skipping warm pings for a window whose reset is more than 24h out. The first-seen-wins resolution and the caller-visible behaviour of everything else are unchanged. Validated as a combined board first (this PR merged with the 21 siblings of the same wave on the release tip): eslint with the frozen suppressions, typecheck:core, check:open-sse-typecheck, complexity, cognitive-complexity, changelog-integrity, i18n new-key coverage, docs-counts, docs-sync, migration-numbering, provider-consistency and a duplicate-identifier audit all green, plus 176 passing / 0 failing focused node:test cases across the 25 test files the wave touches and the dashboard test under Vitest (2/0). Then re-validated alone on the fresh tip before this merge: conflicts re-resolved, file sizes rebaselined for this PR's own growth, eslint and this PR's focused tests re-run. Thank you for keeping each of the four minimal and commented — that is what made this reviewable as one PR.
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
// #13601.2: when upstream response headers exceed the forwarding budget, the
|
|
// drop must be counted/surfaced to the caller — and diagnostic headers
|
|
// (request IDs, retry-after, rate-limit) must win the budget.
|
|
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const { buildStreamingResponseHeaders, resetDroppedHeaderWarnFingerprints } =
|
|
await import("../../open-sse/handlers/chatCore/responseHeaders.ts");
|
|
|
|
const meta = {} as Parameters<typeof buildStreamingResponseHeaders>[1];
|
|
const silentLog = { warn: () => {}, debug: () => {} };
|
|
|
|
function budgetBustingHeaders(): Headers {
|
|
return new Headers({
|
|
"x-request-id": "req-123",
|
|
"retry-after": "30",
|
|
"x-ratelimit-remaining": "10",
|
|
"x-drop-alpha": "a".repeat(600),
|
|
"x-drop-beta": "b".repeat(600),
|
|
});
|
|
}
|
|
|
|
test("#13601.2: a drop count header surfaces silent header drops to the caller", () => {
|
|
resetDroppedHeaderWarnFingerprints();
|
|
const headers = buildStreamingResponseHeaders(budgetBustingHeaders(), meta, silentLog);
|
|
const countHeader = headers["X-OmniRoute-Dropped-Upstream-Headers"];
|
|
assert.ok(countHeader !== undefined, "expected a dropped-headers count header");
|
|
assert.ok(Number.parseInt(countHeader, 10) >= 1, `expected count >= 1, got ${countHeader}`);
|
|
});
|
|
|
|
test("#13601.2: diagnostic headers survive budget pressure", () => {
|
|
resetDroppedHeaderWarnFingerprints();
|
|
const headers = buildStreamingResponseHeaders(budgetBustingHeaders(), meta, silentLog);
|
|
assert.equal(headers["x-request-id"], "req-123");
|
|
assert.equal(headers["retry-after"], "30");
|
|
assert.equal(headers["x-ratelimit-remaining"], "10");
|
|
});
|
|
|
|
test("#13601.2: no drops means no count header", () => {
|
|
resetDroppedHeaderWarnFingerprints();
|
|
const headers = buildStreamingResponseHeaders(
|
|
new Headers({ "x-request-id": "req-1" }),
|
|
meta,
|
|
silentLog
|
|
);
|
|
assert.equal(headers["X-OmniRoute-Dropped-Upstream-Headers"], undefined);
|
|
});
|