diff --git a/.changeset/curvy-owls-grow.md b/.changeset/curvy-owls-grow.md new file mode 100644 index 000000000..8a5434f3f --- /dev/null +++ b/.changeset/curvy-owls-grow.md @@ -0,0 +1,6 @@ +--- +'astro': patch +--- + +* safe guard against TextEncode.encode(HTMLString) [errors on vercel edge] +* safe guard against html.replace when html is undefined \ No newline at end of file diff --git a/packages/astro/src/runtime/server/render/common.ts b/packages/astro/src/runtime/server/render/common.ts index 9b1aa1453..dbb9a6ec5 100644 --- a/packages/astro/src/runtime/server/render/common.ts +++ b/packages/astro/src/runtime/server/render/common.ts @@ -93,5 +93,7 @@ export function chunkToByteArray( if (chunk instanceof Uint8Array) { return chunk as Uint8Array; } - return encoder.encode(stringifyChunk(result, chunk)); + // stringify chunk might return a HTMLString + let stringified = stringifyChunk(result, chunk); + return encoder.encode(stringified.toString()); } diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index b6a6576f1..a2ab2e327 100644 --- a/packages/astro/src/runtime/server/render/component.ts +++ b/packages/astro/src/runtime/server/render/component.ts @@ -261,9 +261,11 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr if (isPage || renderer?.name === 'astro:jsx') { yield html; - } else { + } else if(html && html.length > 0) { yield markHTMLString(html.replace(/\<\/?astro-slot\>/g, '')); - } + } else { + yield ''; + } })(); }