summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Daniel <daniel.freese@gmail.com> 2023-02-01 14:26:45 +0100
committerGravatar GitHub <noreply@github.com> 2023-02-01 08:26:45 -0500
commitf91615f5c04fde36f115dad9110dd75254efd61d (patch)
treeda06efad1c9e0bf3fd39af985b144af6a158cc39
parent94bcf24e45ab95f108433fe28fab4570ccfb8905 (diff)
downloadastro-f91615f5c04fde36f115dad9110dd75254efd61d.tar.gz
astro-f91615f5c04fde36f115dad9110dd75254efd61d.tar.zst
astro-f91615f5c04fde36f115dad9110dd75254efd61d.zip
fix: Failed to execute 'encode' on 'TextEncoder': parameter 1 is not of type 'String' in Edge Runtime SSR (#6070)
* minor fixes for errors related to vercel SSR in core * yielding empty string instead of nothing, to not exit the iterator --------- Co-authored-by: AirBorne04 <>
-rw-r--r--.changeset/curvy-owls-grow.md6
-rw-r--r--packages/astro/src/runtime/server/render/common.ts4
-rw-r--r--packages/astro/src/runtime/server/render/component.ts6
3 files changed, 13 insertions, 3 deletions
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 '';
+ }
})();
}