Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

await race condition - :then block renders twice if the promise is resolved and then changed at the same time #7817

Closed
SystemParadox opened this issue Aug 29, 2022 · 1 comment · Fixed by #7860

Comments

@SystemParadox
Copy link

SystemParadox commented Aug 29, 2022

Describe the bug

If you have an await block and resolve the promise and then change it to a new promise at the same time, the :then block renders twice. If you have any components in this block their onMount will be called twice, but if you later remove them the unmount will only be called once.

Reproduction

https://svelte.dev/repl/d3acebb52bf34f73a17d8afa2ddd19ce?version=3.49.0

Some notes:

  • The Foo component intentionally errors if there are two mounted at the same time, which reveals the bug. If you change this so that foo counts its mounts/unmounts instead you'll see it mounts twice but will only unmount once even if you completely stop rendering it.
  • Note the promise resolving on line 22 and then the selected state changing on line 23 which triggers the reactive statement on 32 and immediately creates a new promise. Changing anything about this causes the bug to disappear.

Logs

No response

System Info

System:
    OS: Linux 5.4 Linux Mint 20.3 (Una)
    CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
    Memory: 8.71 GB / 15.56 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Browsers:
    Chrome: 104.0.5112.79
    Firefox: 103.0.1

svelte@3.49.0

Severity

annoyance

Possibly related

#1591, #5322, #5944, #7806.

@Conduitry
Copy link
Member

This should be fixed now in 3.51.0 - https://svelte.dev/repl/d3acebb52bf34f73a17d8afa2ddd19ce?version=3.51.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants