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 <>
This commit is contained in:
Daniel 2023-02-01 14:26:45 +01:00 committed by Matthew Phillips
parent 7747f0099a
commit 1126c750ed
3 changed files with 13 additions and 3 deletions

View file

@ -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

View file

@ -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());
}

View file

@ -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 '';
}
})();
}