Skip to content

Async effects/promises not immediately flushing #16829

@dangodai

Description

@dangodai

Describe the bug

I have run into a scenario where async code of any kind seems to not immediately be run/flushed. In other words $effect.pending will be stuck > 0 and things like async deriveds will not re-run even when the value they depend on changes. They will eventually be run if something else triggers a flush of pending promises.

I am not certain I have found the minimal reproduction, but after many hours I have narrowed it down to swapping out recursive dynamic components.

Reproduction

Reproduction: https://svelte.dev/playground/eee80b71655641e3b7e0eb5afcb93469?version=5.39.5

This reproduction shows a basic tree structure rendered by the Node component. The displayed Message component contains async work.

Click the "Swap children" button which will replace the existing Message with a pair of Messages nested one level deeper.

Observe that the $effect.pending() displayed is stuck > 0. Observe that the async derived that doubles the input number does not re-run after the initial calculation.

Logs

System Info

System: OS: Linux 6.15 Arch Linux CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor Memory: 4.58 GB / 15.54 GB Container: Yes Shell: 5.3.3 - /bin/bash Binaries: Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node Yarn: 1.22.22 - /usr/bin/yarn npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm pnpm: 10.13.1 - ~/.local/share/pnpm/pnpm Browsers: Chromium: 139.0.7258.66

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions