Skip to content

Common auto-save pattern does not work for inputs #14911

@MathiasWP

Description

@MathiasWP

Describe the bug

Using onblur for autosaving inputs is a common pattern, and it seems that if the save-callback takes more than 100ms then Svelte does not behave as expected.

Related issue: sveltejs/kit#13276

This bug is possible to work around, but it really messes with our mental model of how props/state work. Also note that while setting up the repo it behaved flaky. Sometimes i was not able to trigger the bug at all, while other times it would work with just Promise.resolve() (using no timeout at all to mimic a request). Not sure if this is because of HMR 🤷

Reproduction

Minimal repro: https://svelte.dev/playground/2b6ba5779ffe4ae2ac2e5f493d1d14e0?version=5.16.2

Screen.Recording.2025-01-06.at.13.09.48.mov

Logs

No response

System Info

System:
    OS: macOS 15.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 100.27 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
    pnpm: 9.13.2 - /opt/homebrew/bin/pnpm
    bun: 1.0.0 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 131.1.73.104
    Chrome: 131.0.6778.205
    Edge: 131.0.2903.112
    Safari: 18.2
  npmPackages:
    svelte: ^5.0.0 => 5.16.2

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions