Describe the bug#
Each call to field.handleChange() generates multiple state_proxy_equality_mismatch svelte warning in console.
Your minimal, reproducible example#
https://codesandbox.io/p/devbox/github/tanstack/form/tree/main/examples/svelte/simple?embed=1&theme=dark&file=src/App.svelte
Steps to reproduce#
- Open the simple example for svelte form - https://codesandbox.io/p/devbox/github/tanstack/form/tree/main/examples/svelte/simple?embed=1&theme=dark&file=src/App.svelte
- Open devtools console
- Type anything into first name
- Each keystroke generates 7
state_proxy_equality_mismatch warnings in console.
Reactive `$state(...)` proxies and the values they proxy have different identities. Because of this, comparisons with `===` will produce unexpected results
Expected behavior#
I expect no warning to be in console.
How often does this bug happen?#
Every time
Screenshots or Videos#
Platform#
TanStack Form adapter#
svelte-form
TanStack Form version#
1.33.2
TypeScript version#
No response
Additional context#
The warning appears in version 1.33.0 and up. They do not appear in version 1.32.1 and lower.
The root cause looks like it's upstream in
@tanstack/svelte-storerather than insvelte-form.useSelectorholds the selected slice in a deep-reactive$state, then compares that proxy against the raw value coming back out of the store:defaultCompareisa === b, so on every store update this compares a$stateproxy with its raw target — which is exactly whatstate_proxy_equality_mismatchis designed to flag.The count of 7 per keystroke lines up with
Field.svelte, which creates sevenuseSelectorsubscriptions per field: value/_arrayVersion,isTouched,isBlurred,isDirty,errorMap,errorSourceMap, andisValidating.It's already tracked upstream:
$state.raw, with testsSo this should clear up here once #334 lands, and is likely a duplicate rather than something to fix in
svelte-formitself.