Uh oh!
There was an error while loading. Please reload this page.
Remove flushSync from svelte-db to avoid breaking async compiler mode - #745
Conversation
…r mode Fixes#744 The flushSync() call inside the onFirstReady callback was breaking Svelte 5's async compiler mode. The async compiler enforces a rule that flushSync cannot be called inside effects, as documented at svelte.dev/e/flush_sync_in_effect. The fix removes the flushSync call and updates status directly. Svelte's reactivity system handles the update automatically without needing synchronous flushing. This matches the pattern used in Vue's implementation. Changes: - Removed flushSync() wrapper from onFirstReady callback - Removed unused flushSync import - Updated comment to explain why flushSync cannot be used - All 23 existing tests pass, confirming no regression This fix is backward compatible: - For users WITHOUT async mode (current default): Works as before - For users WITH async mode: Now works instead of throwing error - Future-proof: async mode will be default in Svelte 6
🦋 Changeset detectedLatest commit: 6282d4e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
KyleAMathews
commented
Nov 3, 2025
@wobsoriano does this seem reasonable? |
More templates@tanstack/angular-db@tanstack/db@tanstack/db-ivm@tanstack/electric-db-collection@tanstack/offline-transactions@tanstack/powersync-db-collection@tanstack/query-db-collection@tanstack/react-db@tanstack/rxdb-db-collection@tanstack/solid-db@tanstack/svelte-db@tanstack/trailbase-db-collection@tanstack/vue-dbcommit: |
Size Change: 0 B Total Size: 79.1 kB ℹ️ View Unchanged
|
Size Change: 0 B Total Size: 3.34 kB ℹ️ View Unchanged
|
samwillis
left a comment
There was a problem hiding this comment.
Approving but with the question - do we have a test that validates this statement:
The fix removes the flushSync call and updates status directly. Svelte's reactivity system handles the update automatically without needing synchronous flushing.
Add test to verify that status changes in useLiveQuery properly trigger reactive re-execution in Svelte effects. This validates that accessing query.isReady/isLoading in component templates will automatically re-render when status changes from loading to ready. The test uses $effect() to track execution counts, confirming that Svelte's $state reactivity system works correctly with the status updates that occur via the onFirstReady callback (which doesn't use flushSync in async compiler mode). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
KyleAMathews
commented
Nov 5, 2025
Ah good call — just added an actual test. |
afb711c to
521f838CompareRegenerate docs after adding reactive status change test. All files now use correct PascalCase naming to match main branch. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
521f838 to
36f8e45Compare…ix-bug-011CUk3w5CN4UmLKb7pLVzzT
Update React reference docs to include useLiveSuspenseQuery hook that was added in main. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
Fixes#744
The flushSync() call inside the onFirstReady callback was breaking Svelte 5's async compiler mode. The async compiler enforces a rule that flushSync cannot be called inside effects, as documented at svelte.dev/e/flush_sync_in_effect.
The fix removes the flushSync call and updates status directly. Svelte's reactivity system handles the update automatically without needing synchronous flushing. This matches the pattern used in Vue's implementation.
Changes:
This fix is backward compatible:
🎯 Changes
✅ Checklist
pnpm test:pr.🚀 Release Impact