-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing CSP header for pre-rendered streamed promises #9235
Comments
Ah, good catch. For non-prerendered pages we can use the (Aside: there's arguably no point using streaming with prerendering, but there are cases where e.g. a layout streams some data and some of its children are prerendered while others aren't, so we probably don't want to warn/error in that case.) |
A different solution to this would be to not have html streamed this way for prerendering and instead await all promises. We would have to wrap every solution with The above example would be <script>
// ...
app.init({
..
data: {
data: { normal: 'data' },
streamed: {
delayedData: Promise.resolve({ delayed: 'data' })
}
}
});
</script> |
I don't understand — wouldn't that defeat the object? |
Describe the bug
Streaming promise after prerendering becomes a script tag that isn't included in the automatic CSP header.
This
leads to following error:
this error comes from following line:
Reproduction
Visit :
https://stackblitz.com/edit/streaming-prerender-bug?file=src/routes/+page.server.js
npm run build
(the issue doesn't appear indev
mode)npm run preview
(There are timeouts (≤ 2s) to simulate fetching, so if it looks stuck just wait a second)
Logs
No response
System Info
But also happens on StackBlitz
Severity
annoyance
Additional Information
Can be easily fixed by:
But runtime warning or mention in the docs would be nice,
because the behaviour differs in
dev
and build modes.The text was updated successfully, but these errors were encountered: