-
Notifications
You must be signed in to change notification settings - Fork 375
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?]: Redirects from nested cache
server functions get ignored
#1624
Comments
facing this exact issue with the same use case |
I'm not sure this actually makes sense from a design perspective. Because if we say that we just rethrow then we need to rethrow when it's top-level too which doesn't make sense. There is no one to catch it. Again maybe If anyone has suggestions I'm open to them but I don't really see how this can work. |
Can you elaborate on this? Do you mean that when a
So you are saying that the inner
Fair, maybe part of the issue is my expectation to just wrap anything that fetches data with If the |
Something needs to handle the redirect. Right now the When I put the rethrow logic in I saw the error on the server. The idea here is that Adding an additional router wrapped primitive over createAsync also feels undesirable. Handling stuff like preloads/single fight capture means What I think you want is a way to dedupe server only that is independent of the router mechanism. We really need to rename |
Maybe |
I'm not sure that is enough. If that were the case you could just pull the functions out from the wrappers and reference the internal function. I think you want the deduping behavior, right? |
Would it not be nice for
So what's the issue with this? We could use asynccontext to detect if a cache function is top level or running inside another cache function, and rethrow redirects. |
Can the catching of errors / redirects and the memoization/deduping not be decoupled? so |
If this works I'm surprised. Looking at this if we find a Response we handle it in both cases. https://github.com/solidjs/solid-router/blob/main/src/data/query.ts#L189. This return is what short circuits it in both cases. I'm not sure if the renaming from |
Yeah I realized that my expectations were misaligned with what |
Duplicates
Latest version
Current behavior 😯
When a
cache
server function calls anothercache
server function, any redirects thrown inside the inner function are ignored anundefined
is returned.Expected behavior 🤔
When a
cache
server function calls anothercache
server function, any redirects thrown inside the inner function are rethrown by the outer function.Steps to reproduce 🕹
Reproduction: https://github.com/devagrawal09/solid-start-repro
Context 🔦
I'm trying to define a shared function for auth that can be called on both client and server as needed. This function checks for appropriate headers and throws a redirect if the user is signed out or doesn't have the correct role.
Your environment 🌎
No response
The text was updated successfully, but these errors were encountered: