manubaun
manubaun
Explore posts from servers
SSolidJS
Created by manubaun on 11/15/2024 in #support
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("/");
}
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'
}
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?
8 replies
SSolidJS
Created by manubaun on 9/6/2023 in #support
how to rerender component, when access store prop on component level?
Hi Guys, I have a store, which I have a property to be edited. Once the property is set, a modal should open, if the property is unset, the model closes. something like this:
const [stores, setStore] = createStore({
ticket: { id: 1, name: 'My first ticket' },
});

function TicketModal() {
const ticket = stores.ticket;

createEffect(() => {
console.log(stores.ticket);
});

if (ticket) {
return <>render Modal</>;
}

return <>no Modal</>;
}
const [stores, setStore] = createStore({
ticket: { id: 1, name: 'My first ticket' },
});

function TicketModal() {
const ticket = stores.ticket;

createEffect(() => {
console.log(stores.ticket);
});

if (ticket) {
return <>render Modal</>;
}

return <>no Modal</>;
}
but this wont work. If I wrap my access on the ticket of the store in a create effect, I can see it changes. what I thought of, to create a signal, set the signal via createEffect, and then render the modal. But I like to avoid this approach. is there a better way?
2 replies
TtRPC
Created by manubaun on 7/17/2023 in #❓-help
useSubscription simplified with react query
Hi Guys, looking for a way to simplify the use of useSubscription. Currently I do the following: 1. create local state with the type of my subscription 2. call useSubscription, and pass onData to a setData
import type { UserSchema } from "@app/server/...";
// ...
const [data, setData] = useState<UserSchema[]>([]);

trpc.admin.users.all$.useSubscription(undefined, { onData: (d) => setData(d || []) });
import type { UserSchema } from "@app/server/...";
// ...
const [data, setData] = useState<UserSchema[]>([]);

trpc.admin.users.all$.useSubscription(undefined, { onData: (d) => setData(d || []) });
is there a way, to avoid it like I do? Then I would not need to - import the types, - create a local state, - wiring up useSubscription and localState
1 replies