Skip to content
Source
Sign inSign up
TanStack/form

Svelte form - `state_proxy_equality_mismatch` warnings when calling `field.handleChange()` #2256

Send to my agent
OpenBladesheng(GitHub profile, opens in a new tab) opened this issue 1 comment

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

  1. 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
  2. Open devtools console
  3. Type anything into first name
  4. 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

Image

Platform

  • Chrome 150
  • Rocky Linux

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.

  1. The root cause looks like it's upstream in @tanstack/svelte-store rather than in svelte-form.

    useSelector holds the selected slice in a deep-reactive $state, then compares that proxy against the raw value coming back out of the store:

    // packages/svelte-store/src/useSelector.svelte.ts
    let slice = $state(selector(source.get()))
    
    $effect(() => {
      source.subscribe((s) => {
        const data = selector(s)
        if (compare(slice, data)) return   // proxy === raw
        slice = data
      })
    })

    defaultCompare is a === b, so on every store update this compares a $state proxy with its raw target — which is exactly what state_proxy_equality_mismatch is designed to flag.

    The count of 7 per keystroke lines up with Field.svelte, which creates seven useSelector subscriptions per field: value/_arrayVersion, isTouched, isBlurred, isDirty, errorMap, errorSourceMap, and isValidating.

    It's already tracked upstream:

    So this should clear up here once #334 lands, and is likely a duplicate rather than something to fix in svelte-form itself.

  2. LeCarbonator(GitHub profile, opens in a new tab) added labelsv2: needs investigation

Sign in to join this conversation.