sveltejs / sveltejs/kit

Programmatic invalidation in remote form will prevent error being thrown

Open
#14,706 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

forms needs-decision
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

given - using the new remote form function with enhance()
when - programmatically invalidating something from within the remote form function with invalid()
then - subsequent calls to error() will exit the function but the error will not be thrown on the client
expected - a call to invalid() should not change the behavior of error()

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-e7rfdu7j?file=src%2Froutes%2Fform.remote.ts

Logs

System Info
System:
    OS: Windows 11 10.0.26100
    CPU: (8) x64 Intel(R) Xeon(R) W-2125 CPU @ 4.00GHz
    Memory: 11.57 GB / 31.68 GB
  Binaries:
    Node: 24.9.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.6.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (140.0.3485.54)
    Firefox: 140.0.4 - C:\Program Files\Mozilla Firefox\firefox.exe
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @sveltejs/adapter-node: ^5.2.12 => 5.3.3
    @sveltejs/enhanced-img: ^0.6.0 => 0.6.1
    @sveltejs/kit: ^2.20.2 => 2.46.4
    @sveltejs/vite-plugin-svelte: ^5.0.3 => 5.1.1
    svelte: ^5.33.13 => 5.39.11
    vite: ^6.2.3 => 6.3.6
Severity

annoyance

Additional Information

Ideally, calling error() should not just throw consistently. It would be good if even in the error case the issues raised by the remote function are populated and available to the client. This would allow to pass general error information while also returning proper error codes for further telemetry (not a fan of HTTP 200 with success: false...).
But I'm not sure what exactly the intended design behavior is.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction at src/routes/form.remote.ts and trace how remote form enhance() handles invalid() followed by error(). Confirm the expected client-side error behavior and whether invalid issues should remain available, then reproduce the regression in the relevant test coverage before making the behavior consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
full-stack
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.