Skip to content

Commit 66ea1e6

Browse files
authored
fix(astro): Handle non-utf8 encoded streams in middleware (#9989)
1 parent d0fe7ed commit 66ea1e6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/astro/src/server/middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ async function instrumentRequest(
162162
const newResponseStream = new ReadableStream({
163163
start: async controller => {
164164
for await (const chunk of originalBody) {
165-
const html = typeof chunk === 'string' ? chunk : decoder.decode(chunk);
165+
const html = typeof chunk === 'string' ? chunk : decoder.decode(chunk, { stream: true });
166166
const modifiedHtml = addMetaTagToHead(html, scope, client, span);
167167
controller.enqueue(new TextEncoder().encode(modifiedHtml));
168168
}

0 commit comments

Comments
 (0)