I get ERR_UNHANDLED_REJECTION
Hey all, I am using the solidstart drizzle example wiht login.
solidstartversion: "@solidjs/start": "1.0.6",
nodeversion 23.2
I try to run this code.
the problem I encouter now is, if the the function now returns the error,
nodejs crashes with error message:
I just dont know where I can handle the rejections..
does anyone know, how to resolve that?
7 Replies
In my frontend I use it like this
<form action={loginOrRegister} method="post">
and function is wrapped in an action export const loginOrRegister = action(lOR, "login");
Maybe just return the redirect instead of throwing.
At my phone, can verify atm
in the loginOrRegister function, if the validation fails it create a new error and returns it.
then the same issue happends ERR_UNHANDLED_REJECTION
so its not even reaching redirect
Can't reproduce it.
Maybe you can in a stackblitz?
https://stackblitz.com/edit/github-52ahab?file=src%2Froutes%2Findex.tsx,src%2Fserver.ts
What's your router version?
Unrelated: You'll probaly need to "use server" to the function to be able to get and update the session.
used your code and yes, I cannot reproduce it either. Then tracked down the error.
In my navbar I use a function called getUsers (all from the with-drizzle example)
there it uses
const user = createAsync(async () => getUser(), { deferStream: true });
this is somehow the function, where it all goes bad. I probably use createAsync wrong.
https://stackblitz.com/edit/github-52ahab-xybqhj?file=src%2Froutes%2Findex.tsx,src%2Fserver.ts,src%2Fcomponents%2FNav.tsx
note: In my Stackbliz example I get "Context is not available". On my Mac, I getht the ERR_UNHANDLED_REJECTION crashStackBlitz
Solid-start With Tailwindcss Example (forked) - StackBlitz
Run official live example code for Solid-start With Tailwindcss, created by Solidjs on StackBlitz
the idea is, to show some extra infos and options when user is logged in.
in the drizzle example it uses it on a page like here:
`
Got it.
You can not export actions and query from files with top level "use server", because they need to run on the client.
Move them to another file or place the "use server" directive at the top of the async functions.