Files
OmniRoute/tests/unit/translator-same-format-null-flush.test.ts
Diego Rodrigues de Sa e Souza d0396c200d Release v3.8.31 (#4377)
Release v3.8.31 — see CHANGELOG.md [3.8.31] for full notes and contributors.

Merged over known non-blocking reds (all correctness gates green): Integration Tests (2/2) is env/flaky (polls a real upstream batch that did not complete in the poll window); SonarQube/SonarCloud is the advisory server-side new-code quality gate. Unit (8 shards), Coverage, Node 22/24/26, Lint, PR Test Policy, Quality Ratchet, Docs-Strict, Quality-Extended and all 4 CodeQL analyses are green.
2026-06-20 14:55:24 -03:00

21 lines
961 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
// Regression for port-from-9router#1052: the streaming response translator's
// same-format fast path returned `[chunk]` unconditionally. The null/flush signal
// (chunk === null) therefore leaked a literal `[null]` to downstream consumers,
// which surfaced as an empty `data: null` SSE event between chunks and crashed
// strict clients (e.g. Factory Droid BYOK on /v1/responses).
const { translateResponse } = await import("../../open-sse/translator/index.ts");
test("#1052: same-format null flush yields no chunks (not [null])", () => {
const out = translateResponse("openai", "openai", null, {});
assert.deepEqual(out, []);
});
test("#1052: same-format real chunk still passes through unchanged", () => {
const chunk = { id: "x", choices: [{ delta: { content: "hi" } }] };
const out = translateResponse("openai", "openai", chunk, {});
assert.deepEqual(out, [chunk]);
});