Skip to content

Commit be0f8f6

Browse files
authored
fix: clear result when form client errors (#14337)
If a `fetch` fails because of a network error (e.g. no connection), there will be no `response`. Instead, `fetch` will throw. When this happens, we should still clear the result so it reflects this (just like we do when `!response.ok`).
1 parent 8490711 commit be0f8f6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/kit/src/runtime/client/remote-functions/form.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export function form(id) {
8282
if (!response.ok) {
8383
// We only end up here in case of a network error or if the server has an internal error
8484
// (which shouldn't happen because we handle errors on the server and always send a 200 response)
85-
result = undefined;
8685
throw new Error('Failed to execute remote function');
8786
}
8887

@@ -109,6 +108,7 @@ export function form(id) {
109108
throw new HttpError(500, form_result.error);
110109
}
111110
} catch (e) {
111+
result = undefined;
112112
release_overrides(updates);
113113
throw e;
114114
} finally {

0 commit comments

Comments
 (0)