Skip to content

Commit be3581f

Browse files
committed
fix(qwik-router): submit() always rejects on abort; Form swallows its own rejection
1 parent 8e662a6 commit be3581f

4 files changed

Lines changed: 11 additions & 6 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@qwik.dev/router': patch
3+
---
4+
5+
`action.submit()`/`run()` now always rejects when the submission aborts (a thrown `error()` or unexpected server error) — previously a `SubmitEvent`-based submission resolved with an empty result, letting failures look like successes. `<Form>` handles the rejection internally and keeps emitting `submitcompleted` with `detail.aborted`.

packages/qwik-router/src/runtime/src/form-component.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export const Form = <O, I>(
6565
!reloadDocument
6666
? $((evt: SubmitEvent) => {
6767
if (!action.submitted) {
68-
return action.submit(evt);
68+
// Swallow our own rejection — submitcompleted is the form's abort channel.
69+
return action.submit(evt).catch(() => {});
6970
}
7071
})
7172
: undefined,
@@ -86,7 +87,7 @@ export const Form = <O, I>(
8687
// Since v2, this fires before the action is executed so it can be prevented
8788
onSubmit$,
8889
// action.submit "submitcompleted" event for onSubmitCompleted$ events
89-
!reloadDocument ? action.submit : undefined,
90+
!reloadDocument ? $((evt: SubmitEvent) => action.submit(evt).catch(() => {})) : undefined,
9091
],
9192
method: 'post',
9293
['data-spa-reset']: spaReset ? 'true' : undefined,

packages/qwik-router/src/runtime/src/server-functions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ Action.run() can only be called on the browser, for example when a user clicks a
134134
detail: detail,
135135
})
136136
);
137-
return { status, value: undefined, error: undefined };
138137
}
139138
throw aborted;
140139
}

packages/qwik-router/src/runtime/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -988,9 +988,9 @@ export type ActionStore<RETURN, INPUT, OPTIONAL extends boolean = true, ERROR =
988988
* action in the server.
989989
*
990990
* Resolves with `{ status, value, error }` — expected failures (a returned `fail()` or a failed
991-
* validator) come back on `error`. A programmatic invocation rejects when the submission aborts
992-
* (a thrown `error()` or an unexpected server error); `<Form>` submissions surface aborts via the
993-
* `submitcompleted` event's `detail.aborted` instead.
991+
* validator) come back on `error`. REJECTS when the submission aborts (a thrown `error()` or an
992+
* unexpected server error). `<Form>` handles this rejection internally and surfaces aborts via
993+
* the `submitcompleted` event's `detail.aborted`.
994994
*/
995995
readonly submit: QRL<
996996
OPTIONAL extends true

0 commit comments

Comments
 (0)