Skip to content

Conversation

Jeelislive
Copy link

@Jeelislive Jeelislive commented Oct 3, 2025

[Bug] Fixes issue where $effect does not run immediately after an async derived resolves unless another “wakeup” occurs.

[Change] In async_derived()’s handler, when the derived did not suspend and the boundary is not pending, explicitly flush and deactivate the current batch so user effects run right away.

[modified] packages/svelte/src/internal/client/reactivity/deriveds.js
In async_derived.handler:

- After internal_set(signal, value), if !should_suspend && !pending, call:
    - batch.flush();
    - batch.deactivate();

Behavior before vs after:

  • Before: $effect runs only after a subsequent wake/wakeup following async derived resolution.
  • After: $effect runs immediately after the async derived resolves in the non-suspend path.

Related

Copy link

changeset-bot bot commented Oct 3, 2025

⚠️ No Changeset found

Latest commit: ef964f2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svelte-docs-bot
Copy link

Copy link
Contributor

github-actions bot commented Oct 3, 2025

Playground

pnpm add https://pkg.pr.new/svelte@16884

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 this pull request may close these issues.

$effect does not run after async derived completes, but after the next wakeup
1 participant