-
-
Notifications
You must be signed in to change notification settings - Fork 956
fix: SSR invariant dehydration errors with bun #4228
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
base: main
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit 846bf44.
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/directive-functions-plugin
@tanstack/history
@tanstack/react-router
@tanstack/eslint-plugin-router
@tanstack/react-router-devtools
@tanstack/react-router-with-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-config
@tanstack/react-start-plugin
@tanstack/react-start-router-manifest
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-config
@tanstack/solid-start-plugin
@tanstack/solid-start-router-manifest
@tanstack/solid-start-server
@tanstack/start
@tanstack/start-api-routes
@tanstack/start-client-core
@tanstack/start-config
@tanstack/start-server-core
@tanstack/start-server-functions-client
@tanstack/start-server-functions-fetcher
@tanstack/start-server-functions-handler
@tanstack/start-server-functions-server
@tanstack/start-server-functions-ssr
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
I think it would be better if ensure that all tsr-once is before the entry script |
that's not possible as values might stream in later |
how can I reproduce the issue locally? |
Related: #3989
The script assigned to
__TSR_SSR__.dehydrated
appears outside the</html>
tag. When the entry script/_build/assets/client-BJoNZ2zg.js
is cached locally by the browser, even if the entry script is async, the script outside the html may still be executed after the entry script.router/packages/start-server-core/src/transformStreamWithRouter.ts
Line 171 in 72ffeb4
Problems occur when
text
is complete HTMLrouter/packages/start-server-core/src/transformStreamWithRouter.ts
Lines 174 to 175 in 72ffeb4
router/packages/start-server-core/src/transformStreamWithRouter.ts
Line 190 in 72ffeb4
bodyEndMatch
is assigned before the!headStarted
branch processes chunkString.router/packages/start-server-core/src/transformStreamWithRouter.ts
Line 216 in 72ffeb4
The length of
bodyEndIndex
obtained here will exceed the length of the modifiedchunkString
, resulting in<script>
being appended after</html>
The solution is to move
bodyEndMatch
andhtmlEndMatch
to after thechunkString
change.