Skip to content
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

Open
dotnize opened this issue Jan 15, 2025 · 7 comments
Open

1.97 Server fn headers are incomplete on initial load #3173

dotnize opened this issue Jan 15, 2025 · 7 comments

Comments

@dotnize
Copy link

dotnize commented Jan 15, 2025

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

  1. Clone repo and run dev
  2. Load any page. Headers returned and logged from server fn loader will be incomplete.
  3. Navigate to /test or /. Complete headers are now returned.

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

  • OS: [Linux]
  • Browser: [Chrome, Firefox]

Additional context

No response

@tannerlinsley
Copy link
Collaborator

I have an inkling of why this is happening. I’ll look into it today.

@einarno
Copy link

einarno commented Jan 17, 2025

For anyone depending on this 1.95.7 is the last version without this issue

@noah-wardlow
Copy link

seeing this too, but also on getHeaders() function. will also note 1.95.7 works as expected

@timoconnellaus
Copy link
Contributor

timoconnellaus commented Jan 19, 2025

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)

@prateekkumarweb
Copy link

Not just headers, even getCookies() returns undefined.

@tannerlinsley
Copy link
Collaborator

Cookies are powered by headers on the server. So that makes sense. I’m working on it!

@michaeldahl7
Copy link

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)

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 ^.

dotnize added a commit to dotnize/tanstarter that referenced this issue Jan 22, 2025
@dotnize dotnize changed the title 1.97 Server fn getWebRequest headers are incomplete on initial load 1.97 Server fn headers are incomplete on initial load Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

7 participants