Preserve server issues when doing preflight-only validation - #14759
Conversation
…r preflight-only issues
|
|
is it on purpose that this is targeting main and not the other branch? |
|
nope — good catch |
dummdidumm
left a comment
There was a problem hiding this comment.
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.
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
* 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>
* 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>
`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:`.
#14744 (comment)