fix(core): use TextDecoderStream for stream response (#1498)

This commit is contained in:
Reo 2024-06-17 02:27:37 +09:00 • committed by GitHub
parent 791a75f7a3
commit 09d256ad56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,13 +9,9 @@ export async function* streamResponse(
throw new Error("No response body returned.");
}
const stream = response.body as any;
const stream = (ReadableStream as any).from(response.body);
const decoder = new TextDecoder("utf-8");
for await (const chunk of stream) {
yield decoder.decode(chunk, { stream: true, });
}
yield* stream.pipeThrough(new TextDecoderStream("utf-8"));
}
function parseDataLine(line: string): any {