You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a bug with Router/Start streaming SSR when
the route component suspends
the loader returns a ReadableStream
the stream has a fast first chunk
Under these circumstances, the generated HTML is out of order, containing these three <script tags in this order:
<scriptclass="tsr-once ">__TSR__.initMatch({"index": 0,"__beforeLoadContext": "{}","loaderData": "{\"$undefined\":0}","extracted": {}})console.info(`Injected From Server:__TSR__.initMatch({"index":0,"__beforeLoadContext":"{}","loaderData":"{\\"$undefined\\":0}","extracted":{}})`)if(typeof__TSR__!=="undefined")__TSR__.cleanScripts()</script>
<scriptclass='tsr-once'>__TSR__.matches[1].extracted[1].value.controller.enqueue(newTextEncoder().encode("this is too soon!"));console.info(`Injected From Server:__TSR__.matches[1].extracted[1].value.controller.enqueue(new TextEncoder().encode("this is too soon!"))`);if(typeof__TSR__!=='undefined')__TSR__.cleanScripts()</script>
Note that the second script tag tries to access __TSR__.matches[1].extracted[1] - the problem here is that __TSR__.matches[1] will only be initialized as a result of the third script tag, so a Uncaught TypeError: __TSR__.matches[1] is undefined error is thrown.
Which project does this relate to?
Start
Describe the bug
This is a bug with Router/Start streaming SSR when
Under these circumstances, the generated HTML is out of order, containing these three
<script
tags in this order:Note that the second
script
tag tries to access__TSR__.matches[1].extracted[1]
- the problem here is that__TSR__.matches[1]
will only be initialized as a result of the third script tag, so aUncaught TypeError: __TSR__.matches[1] is undefined
error is thrown.Your Example Website or App
https://stackblitz.com/~/github.com/phryneas/reproduction-tanstack-router-chunk-stream-order-bug?file=app/routes/index.tsx
Steps to Reproduce the Bug or Issue
Open the console and see the bug.
Expected behavior
The chunk should arrive after the controller is initialized in the browser.
Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: