Skip to content

cancelling submission in form.enhance does not reset pending count #15519

Description

@AndreasHald

Describe the bug

When you in a remote form does not call submit in the enhance function pending_count is never reset

{myForm.pending}
<form {...myForm.enhance(async ({data, submit}) => {
// don't submit for whatever reason could be a confirm step
})}>
<!-- ... -->
</form>

If you do this pending will be incremented and never go down.

The issue is here

Pending is incremented on line 116 when handle_submit is called on line 160 the callback is invoked. but pending only decrement within the submit function, so if the callback returns without calling submit it never is.

	try {
				await callback({
					form,
					data,
					submit: () => submit(form_data)
				});
			} catch (e) {
				const error = e instanceof HttpError ? e.body : { message: /** @type {any} */ (e).message };
				const status = e instanceof HttpError ? e.status : 500;
				void set_nearest_error_page(error, status);
			}

Reproduction

Easier to explain in code above.

Logs

System Info

System:
    OS: macOS 26.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 737.97 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.13.0 - /Users/hald/.nvm/versions/node/v24.13.0/bin/node
    npm: 11.6.2 - /Users/hald/.nvm/versions/node/v24.13.0/bin/npm
  Browsers:
    Chrome: 145.0.7632.160
    Edge: 145.0.3800.97
    Firefox: 137.0.2
    Safari: 26.3
  npmPackages:
    @sveltejs/adapter-vercel: ^6.3.0 => 6.3.3 
    @sveltejs/kit: ^2.53.2 => 2.53.2 
    @sveltejs/vite-plugin-svelte: ^6.1.1 => 6.2.1 
    svelte: ^5.53.7 => 5.53.7 
    vite: ^7.3.0 => 7.3.0

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions