-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SvelteKit: errors from server are treated as success #277
Comments
I have the same problem. While the error is being fixed, is there any workaround? |
I've been trying to reproduce this and I can't. But looking at your screenshots more closely, I think your |
The server already returns it in the shape felte should understand.
Either way, onError isn't being called.
…On Thu, Nov 9, 2023, 16:52 Pablo Berganza ***@***.***> wrote:
I've been trying to reproduce this and I can't. But looking at your
screenshots more closely, I think your onError function is not
transforming the data the server is returning into something Felte
understands :o It looks like it is returning the whole response object.
—
Reply to this email directly, view it on GitHub
<#277 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD2UU33US7G2OTRUKUPANYTYDVNDNAVCNFSM6AAAAAA6N5BQBWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBUHAYDMNZVG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Same here. Specifically, I think the problem is as follows:
Either I am overlooking something or this is just not being handled right now. In any case, an easy workaround is having a condition inside import { fail } from '@sveltejs/kit';
import type { Actions } from '@sveltejs/kit';
export const actions: Actions = {
default: () => {
const someData = {
foo: 'hello',
bar: 'world'
};
return fail(400, someData);
}
}; the returned http status is 200 and the response object looks like the one from @Bubbet: if (response.ok) return response;
throw new FelteSubmitError(
'An error occurred while submitting the form',
response
); However, SvelteKit returns status 200 even on failure. To distinguish both cases, an object with three keys |
Describe the bug
When you fail(400, {errors: {the shape of yup validator's errors}, values: old_form_data_values}) it doesn't update the page.form, and doesn't call onError so those errors are just lost to the void.
As mentioned in the title, the response does trigger onSuccess.
It does catch actual exceptions in the form action.
Which package/s are you using?
felte (Svelte)
Environment
To reproduce
Return fail in a sveltekit form action.
Small reproduction example
No response
Screenshots
Additional context
No response
The text was updated successfully, but these errors were encountered: