fix(types): align stream failure callback contracts (#9561)

Merge-train validated (tip 6ce4effef8). Vitest failures confirmed as base-red (#9679).
This commit is contained in:
backryun
2026-08-08 08:53:57 +09:00
committed by GitHub
parent 0a1f84f83f
commit 4da8ef47c3
2 changed files with 4 additions and 3 deletions

View File

@@ -2778,7 +2778,7 @@ export function createSSETransformStreamWithLogger(
body: unknown = null,
onComplete: ((payload: StreamCompletePayload) => void) | null = null,
apiKeyInfo: unknown = null,
onFailure: ((payload: StreamFailurePayload) => void | Promise<void>) | null = null,
onFailure: ((payload: StreamFailurePayload) => boolean | void | Promise<void>) | null = null,
copilotCompatibleReasoning = false,
suppressThinkClose = false,
customToolNames: ReadonlySet<string> = new Set(),
@@ -2813,7 +2813,7 @@ export function createPassthroughStreamWithLogger(
body: unknown = null,
onComplete: ((payload: StreamCompletePayload) => void) | null = null,
apiKeyInfo: unknown = null,
onFailure: ((payload: StreamFailurePayload) => void | Promise<void>) | null = null,
onFailure: ((payload: StreamFailurePayload) => boolean | void | Promise<void>) | null = null,
clientResponseFormat: string | null = null,
requestToolIdentityMap: Map<string, { namespace: string; name: string }> | null = null
) {

View File

@@ -48,13 +48,14 @@ test("createStreamFailureFinalizers: caller classification survives into respons
persistFailureUsage: () => {},
});
handleStreamFailure({
const handled = handleStreamFailure({
status: 502,
message: "Upstream stream error",
code: "stream_pipeline_error",
type: "stream_error",
});
assert.equal(handled, true, "the callback contract reports that the stream failure was handled");
const body = captured as { error: { type?: string; code?: string } };
assert.equal(body.error.type, "stream_error");
assert.equal(body.error.code, "stream_pipeline_error");