solid-start
solid-start copied to clipboard
[Bug?]: Server functions that throw or return redirects when called in an action do not redirect
Duplicates
- [X] I have searched the existing issues
Latest version
- [X] I have tested the latest version
Current behavior 😯
A server function called from an action (that is not the action itself) that return or throw a redirect to not redirect.
Works:
- Action (client or server) => return/throw redirect
Does not work:
- Action (client or server) => calls a server function => return/throw redirect
The latter works only if you manually propagate the response.
For example in an action:
// validate things
return await myServerFunc() // can redirect
But not when just using the response of the server function in other ways:
// validate things
const data = await myServerFunct() // redirect ignored
// do other things
return 'OK'
This means there is no consistent way to have redirects work from server functions.
Expected behavior 🤔
If a server function throws or returns a redirect then the calling action should respect that and propagate the redirect.
Steps to reproduce 🕹
Steps:
- create a server function that throws a redirect
- create an action that calls the server function, ignoring the results (do not return the results of the server function back from the action)
- see that no redirect happened
Context 🔦
No response
Your environment 🌎
No response