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

bug: Caching too hard, when working with headers #5727

Open
1 task done
iduuck opened this issue May 17, 2024 · 0 comments
Open
1 task done

bug: Caching too hard, when working with headers #5727

iduuck opened this issue May 17, 2024 · 0 comments

Comments

@iduuck
Copy link
Contributor

iduuck commented May 17, 2024

Provide environment information

Not needed in this case.

Describe the bug

When working with headers (like having something in the middleware that sets a header for the request, which tRPC is picking up – let's say auth), and then switching the header, the experimental_createTRPCNextAppDirClient method is caching this way to hard. The headers are not included in the caching mechanism.

So i.e. in my application it's like this:

  • I have a middleware, which sets the ID of the tenant, based on the id param from the route (this is because tRPC doesn't know all the time, where I am calling the API from).
  • Now, I am fetching the header in the headers() method, that I am supplying to the experimental_createTRPCNextAppDirClient call.
  • See, that my header is still not changed, but the call is not being made at all (cache is being used).
  • This is the case for like 1 minute, after which (I actually don't know why) the cache is being cleared, and the request is being done normally.

I think the cache shouldn't be there on a "client"-side, but on the link-side.


Related: #5625

Link to reproduction

Not yet...

To reproduce

Working on a reproduction...

Additional information

No response

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR fixing this bug!

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant