-
-
Notifications
You must be signed in to change notification settings - Fork 751
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
1.97 Server fn headers are incomplete on initial load #3173
Comments
I have an inkling of why this is happening. I’ll look into it today. |
For anyone depending on this 1.95.7 is the last version without this issue |
seeing this too, but also on |
I can't seem to get this on any version including 1.95.7. I cloned the test repo above and I see the issue with 1.95.7 and 1.97.3 (latest) |
Not just headers, even |
Cookies are powered by headers on the server. So that makes sense. I’m working on it! |
Make sure your package json doesn't have the ^ in front of the version number. If tanstack/start is ^1.95.7 it would update to 1.97.x due to the ^. |
@tannerlinsley any update for this one, it prevents us from using the new React 19 and streaming stuff :D, let me know if I can help in any way |
Should be fixed with #3256 |
Hey @tannerlinsley, https://gyazo.com/eb5086a22b05d4b28cf11f4c0eae9d74 The error:
Sorry commented in the merge request by accident initially |
also still seeing this issue |
Lovely! Back to the drawing board. |
Are you using see #2010 (comment) |
Was just using the example that was here https://github.com/dotnize/tss-webrequest-server-fn but it was also happening for me with better-auth it was both cookies and better-auth but now just better-auth doing it. I am making a repo to replicate it now I get the auth data by doing in __root.tsx which is just a server function. that gets Vinxi/http context. This was working prior to the update
|
Here is an example git repo. This was the same code I had before the update when it was working but cut down. |
Tried your repo and the issue for me was Instead of accessing the auth data via Route.useContext() directly, add a loader that re-returns the context data and use export const Route = createFileRoute('/')({
component: Home,
+ loader: ({ context }) => {
+ return { auth: context.auth }
+ }
})
function Home() {
- const { auth } = Route.useRouteContext();
+ const { auth } = Route.useLoaderData(); This makes the auth stuff work for me. Besides that, the other hydration error is probably caused by the theme script. This is no longer related to headers but I've updated my repro for the useRouteContext issue. Replacing them with useLoaderData fixes it. |
@dotnize can this issue be closed? |
Yeah if @nick22985 is still experiencing the hydration error even after the fix I mentioned then it's probably a different issue, not with headers. Thank you! |
Yes ty. Making it use the loader fixes the issue. Thank you all! |
Which project does this relate to?
Start
Describe the bug
In Start 1.97, request headers and cookies from helper functions in @tanstack/start/server or vinxi/http (e.g. getWebRequest) are initially incomplete in server functions called in loaders/beforeLoad, breaking auth stuff.
When navigating/loading another page which will re-trigger beforeLoad, getWebRequest() returns the complete headers.
Your Example Website or App
https://github.com/dotnize/tss-webrequest-server-fn
https://tss-webrequest-server-fn.vercel.app/
Steps to Reproduce the Bug or Issue
This is reproducible in dev and build.
Expected behavior
Complete headers are always returned by getWebRequest in 1.95.x
Screenshots or Videos
Screencast.From.2025-01-15.16-54-05.mp4
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: