mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-01 21:02:12 +03:00
The streaming response translator's same-format fast path returned `[chunk]` unconditionally, so the end-of-stream null/flush signal (chunk === null) propagated as a literal `[null]`. Downstream this surfaced as an empty `data: null` SSE event between chunks and crashed strict clients (e.g. Factory Droid BYOK on /v1/responses). The fast path now returns `[]` for the null flush while still passing real chunks through unchanged. Reported-by: thaitryhand (https://github.com/decolua/9router/issues/1052) Co-authored-by: thaitryhand <248103256+thaitryhand@users.noreply.github.com>
21 lines
961 B
TypeScript
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]);
|
|
});
|