Oddities rendering ReadableStream
#4828
Labels
- P2: nice to have
Not breaking anything but nice to have (priority)
ReadableStream
#4828
What version of
astro
are you using?1.2.6
Are you using an SSR adapter? If so, which one?
Netlify edge
What package manager are you using?
npm
What operating system are you using?
mac
Describe the Bug
We (@matthewp and I) already had a twitter thread going on about this issue here, as well as some discussion on the Discord #netlify channel, but stuff tends to easily get lost in those channels, and I wanted to make a more complete/detailed summary of the issue.
Usecase
When using Astro in SSR mode on Netlify Edge, I'd like to
fetch
HTML, and stream the result of the HTML to the browser. My code looks as follows:During local development using Node v16, if I refresh the page, I can clearly see that the HTML is correctly being streamed to the browser.
Once deployed on Netlify Edge, however, it seems to output/stringify a
Uint8Array
instead:Investigation
Since Netlify Edge runs on Deno, and locally I'm running Astro with Node, I initially thought this might be a difference between the environments. So I tried to create a minimal reproduction of the rendering logic found here.
My reproduction looks like this:
However, this outputs (in both Deno and Node):
If I add the following code (taken from @natemoo-re 's Microstream here):
The output I get is (as expected):
It's super confusing however that in the first example, the output is a
Uint8Array
, since during local development I definitely see the HTML being streamed:stream.mov
So the problem is:
Why does Astro output a
Uint8Array
on Netlify Edge?Bonus question:
How is it possible that in my minimal reproduction I'm seeing the
Uint8Array
being output on Node, whereas in local development with Astro on Node, I'm seeing the HTML being streamed?I'll continue to dig into this/debug this some more as well in the meantime, and will update this issue if I've made any progress.
Links
renderChild
logicReadableStream
sLink to Minimal Reproducible Example
see post
Participation
The text was updated successfully, but these errors were encountered: