#basically both code sample are not
1 messages · Page 1 of 1 (latest)
The point is not that they should be equivalent, it's just that having the first block of code with then().catch() actually makes the second block work
Any hints would be highly appreciated, I'm out of ideas here
sorry but it's tad unclear, you are showing a piece of code that is wrong and say it works so it's weird, the second piece is more correct but doesn't work: what do you mean by doesn't work?
Sorry for being vague. The await never resolves in the second code, but it does in the first one
The server function looks like this (roughly):
'use server';
export const handlePastedData = async (url: string): Promise<PastedSchema | null> => {
...
return data;
};
and I wonder how you test if it resolves
cause you don't have any error catching logic
so their might be an error but not visible
maybe start with adding a try catch at least
I actually have this big try/catch around the code in the handlePastedData function:
try {
...
return data;
} catch (error) {
console.error('An error occurred:', error);
return null;
} finally {
if (page) {
await page.close();
}
if (browser) {
await browser.close();
}
}
If I console log the data before returning it prints the correct value
perhaps "onPaste" is not correctly awaited?
I feel like the "working version" just works because of some race condition
so something is off somewhere, like a function not awaiting the result etc.
I can get the pasted value before calling the function, but yeah something is off, but it's not only that. I use server actions all over in my app and none of them are resolving promises at the moment
I've tried to remove both the .next directory and node_modules with a fresh install and restarted the dev server, but no luck
ah ok if it's everywhere it might be something off indeed, server actions are alpha
Yup, I'm creating a minimal reproduction example at the moment to see if it is some configuration on my end or actually a bug
It was an error on my side. The expire date on the jwt had run out and I didn't handle it. Thanks for the help!