Skip to content

Preserve server issues when doing preflight-only validation - #14759

Merged
Rich-Harris merged 5 commits into
preflight-onlyfrom
preflight-only-merge-issues
Oct 19, 2025
Merged

Preserve server issues when doing preflight-only validation#14759
Rich-Harris merged 5 commits into
preflight-onlyfrom
preflight-only-merge-issues

Conversation

@Rich-Harris

@Rich-Harris Rich-Harris commented Oct 19, 2025

Copy link
Copy Markdown
Member

@changeset-bot

changeset-bot Bot commented Oct 19, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4a79f2c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown

@dummdidumm

Copy link
Copy Markdown
Member

is it on purpose that this is targeting main and not the other branch?

@dummdidumm
dummdidumm changed the base branch from main to preflight-only October 19, 2025 18:25
@Rich-Harris

Copy link
Copy Markdown
Member Author

nope — good catch

@dummdidumm dummdidumm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice - didn't look closely enough at first which caused my concern-post in the related PR about client-side overriding server-side validation. I now see that it keeps all server-side issues intact for issues that are NOT overridden by client-side issues, which is indeed better.

Comment thread packages/kit/src/runtime/client/remote-functions/form.svelte.js Outdated
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
@Rich-Harris
Rich-Harris merged commit d68fdb9 into preflight-only Oct 19, 2025
17 of 18 checks passed
@Rich-Harris
Rich-Harris deleted the preflight-only-merge-issues branch October 19, 2025 21:05
Rich-Harris added a commit that referenced this pull request Oct 19, 2025
* feat: allow to run preflight validation only

That way you can e.g. run preflight on each keystroke and full validation only on blur

* clientOnly -> preflightOnly

* Preserve server issues when doing preflight-only validation (#14759)

* preserve server issues on preflight validation, unless there are newer preflight-only issues

* sort correctly

* no longer necessary

* lint

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

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
Copilot AI pushed a commit to Stadly/kit that referenced this pull request Mar 6, 2026
* feat: allow to run preflight validation only

That way you can e.g. run preflight on each keystroke and full validation only on blur

* clientOnly -> preflightOnly

* Preserve server issues when doing preflight-only validation (sveltejs#14759)

* preserve server issues on preflight validation, unless there are newer preflight-only issues

* sort correctly

* no longer necessary

* lint

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

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
Rich-Harris pushed a commit that referenced this pull request Jul 29, 2026
`merge_with_server_issues` runs whenever preflight validation produces
issues, which with the documented `oninput` pattern means on every
keystroke while a form has issues. Merging costs O(S·C + M·K·log M) for
S server issues, C client issues, M merged issues and K form keys. 🤓
This change drops it to O(S + C + K + M·log M). 🤓

N fields with N issues (half server, half client), Node 22 x64, median
of repeated runs:

| fields | before | after | speedup |
| ---: | ---: | ---: | ---: |
| 400 | 1.6 ms | 0.1 ms | 15× |
| 800 | 7.9 ms | 0.3 ms | 27× |
| 1600 | 33.0 ms | 0.8 ms | 42× |
| 3200 | 163.8 ms | 2.2 ms | 76× |

Small forms are at parity or slightly faster, since the old code already
allocated the key array.

Output is unchanged: identical issue-object ordering to the previous
implementation across 10,000 randomized cases covering duplicated form
keys, duplicated issue names, names absent from the form, mixed server
and client issues and empty collections. The merge semantics negotiated
in #14744/#14759 are preserved.

---

### Before submitting the PR, please make sure you do the following

- [ ] It's really useful if your PR references an issue where it is
discussed ahead of time. In many cases, features are absent for a
reason. For large changes, please create an RFC:
https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it
solves.
- [ ] Ideally, include a test that fails without this PR but passes with
it.

### Tests

- [x] Run the tests with `pnpm test` and lint the project with `pnpm
lint` and `pnpm check`

### Changesets

- [x] If your PR makes a change that should be noted in one or more
packages' changelogs, generate a changeset by running `pnpm changeset`
and following the prompts. Changesets that add features should be
`minor` and those that fix bugs should be `patch`. Please prefix
changeset messages with `feat:`, `fix:`, or `chore:`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants