SolidJSS
SolidJSโ€ข15mo agoโ€ข
7 replies
manubaun

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.
export async function loginOrRegister(formData: FormData) {
    const username = String(formData.get("username"));
    const password = String(formData.get("password"));
    const loginType = String(formData.get("loginType"));

    let error = validateUsername(username) || validatePassword(password);
    if (error) return new Error(error);

    try {
        const user = await (loginType !== "login" ? register(username, password) : login(username, password));

        createRedmineClient({
            username: username,
            password: password,
        });

        const session = await getSession();
        await session.update((d) => {
            d.userId = user.id;
        });
    } catch (err) {
        return err as Error;
    }
    throw redirect("/");
}


the problem I encouter now is, if the the function now returns the error,
nodejs crashes with error message:

node:internal/process/promises:392
      new UnhandledPromiseRejection(reason);
      ^

UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<_Response>".
    at throwUnhandledRejectionsMode (node:internal/process/promises:392:7)
    at processPromiseRejections (node:internal/process/promises:475:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:106:32) {
  code: 'ERR_UNHANDLED_REJECTION'
}


I just dont know where I can handle the rejections..

does anyone know, how to resolve that?
Was this page helpful?