Skip to main content
Lightning Jar - Web Studio Lightning Jar Wordmark

Findings No. 47

`await update()` resets the form by default, and that can hide or cause a bug

SvelteKit's use:enhance update() defaults to reset: true, wiping bind:value fields. A re-sync $effect keyed on object reference had been masking it in Replicator.

Replicator SvelteKit verified SvelteKit use:enhance with Svelte 5 runes

In SvelteKit, await update() inside use:enhance resets the form unless you pass { reset: false }. On a form whose fields use bind:value, that reset clears your state through the two-way binding.

In Replicator's blog editor this hid behind a second bug. A $effect called reset(data.article) whenever data.article changed by reference. After every save, update() reruns load, which produces a new object with the same id, so the effect fired and overwrote the just-saved state. Metadata fields blanked after saving and came back only on a full reload. We fixed the effect to key on identity, data.article.id, and that exposed the first bug: the default form.reset() was now wiping the bound fields, and the broken effect had been accidentally refilling them from the reloaded data.

The complete fix was both changes: sync effects keyed on the source's id, and every update() call on a stateful form passing { reset: false } explicitly.

The general rule: when a fix exposes a new bug, suspect that the old bug was compensating for it. And for any form with bound state, decide about reset deliberately instead of inheriting the default.

Receipt: Replicator v3.73.10 to v3.73.11 (FINDINGS.md, "Svelte 5 runes and reactivity").

Ask Eljay

Ask about the studio's work, research, packages, or writing. A few starters:

Answers come from this site's own content and link their sources. For anything that matters, email hello@lightningjar.com.