Undocumented edge case - early return of non-trailing `validate` calls on complex remote form
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
When calling .validate programmatically on a "complex-enough" remote form, only the trailing edge will actually execute the necessary logic, all prior calls return early - a kind of debouncing I assume. This claim is based on my understanding of the relevant source code at current HEAD:
This may lead to some unexpected behavior. The reproduction shows such case when validate is called twice shortly after one another, falsely masking validation issue in one of the two logic flows. This mimics an occurrence in a project of mine when user tries to click on a button while the focus is still on the input containing invalid data - both button onclick and form onchange call validate.
Ideally, I'd expect all debounced calls to also return the same Promise the trailing edge does. But if this is not negotiable, perhaps a note in the documentation should help others avoid the same rabbit hole I went down.
Reproduction
Please see https://github.com/vnphanquang/remote-form-repeat-validate for details.
Essentially, the repro tries to simulate a large form so that the init of FormData is slowed down enough for multiple calls of validate to be debounced. I presume similar issue may also be observed when there is some complex state derivation/dependency. issues is not populated after cancelled calls, hence the problem.
System Info
System:
OS: Linux 6.18 Arch Linux
CPU: (12) x64 AMD Ryzen 5 7500F 6-Core Processor
Memory: 21.53 GB / 30.93 GB
Container: Yes
Shell: 4.3.3 - /usr/bin/fish
Binaries:
Node: 24.12.0 - $HOME/.volta/tools/image/node/24.12.0/bin/node
npm: 11.6.2 - $HOME/.volta/tools/image/node/24.12.0/bin/npm
pnpm: 10.26.0 - $HOME/.volta/bin/pnpm
Browsers:
Firefox: 147.0.1
Firefox Developer Edition: 147.0.1
npmPackages:
@sveltejs/adapter-node: ^5.5.4 => 5.5.4
@sveltejs/kit: ^2.55.0 => 2.55.0
@sveltejs/vite-plugin-svelte: ^7.0.0 => 7.0.0
svelte: ^5.53.11 => 5.53.11
vite: ^8.0.0 => 8.0.0
Severity
annoyance
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/kit/src/runtime/client/remote-functions/form.svelte.js at lines 525-527, then run the remote-form-repeat-validate reproduction to observe repeated validate calls on a complex form. Determine the expected behavior for cancelled calls and their Promises; done when the behavior is resolved or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100