From 3567afac4411c1054a5e999dd692e6d079825b4a Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 24 Jul 2023 16:22:05 +0800 Subject: [PATCH] Fix rendering TextEncoder encoding error regression (#7777) --- .changeset/dry-cycles-appear.md | 5 +++++ packages/astro/src/runtime/server/render/common.ts | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/dry-cycles-appear.md diff --git a/.changeset/dry-cycles-appear.md b/.changeset/dry-cycles-appear.md new file mode 100644 index 0000000000..574c15665c --- /dev/null +++ b/.changeset/dry-cycles-appear.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix rendering TextEncoder encoding error regression diff --git a/packages/astro/src/runtime/server/render/common.ts b/packages/astro/src/runtime/server/render/common.ts index b2d41bd54b..206f138cc8 100644 --- a/packages/astro/src/runtime/server/render/common.ts +++ b/packages/astro/src/runtime/server/render/common.ts @@ -124,7 +124,8 @@ export function chunkToByteArray( if (ArrayBuffer.isView(chunk)) { return chunk as Uint8Array; } else { - // stringify chunk might return a HTMLString - return encoder.encode(stringifyChunk(result, chunk)); + // `stringifyChunk` might return a HTMLString, call `.toString()` to really ensure it's a string + const stringified = stringifyChunk(result, chunk); + return encoder.encode(stringified.toString()); } }