fix electric collection progressive mode #852
Mergedsamwillis(GitHub profile, opens in a new tab)merged 7 commits into
main fromrefs/pull/852/headmerged by samwillis(GitHub profile, opens in a new tab) KyleAMathews(GitHub profile, opens in a new tab) approved these changes
- @@ -669,3 +694,9 @@669694 sync: (params: Parameters<SyncConfig<T>[`sync`]>[0]) => {670695 const { begin, write, commit, markReady, truncate, collection } = params671696697+ // Wrap markReady to wait for test hook in progressive mode698+ let progressiveReadyGate: Promise<void> | null = null699+ const wrappedMarkReady = () => {700+ // Only create gate if we're in buffering phase (first up-to-date)701+ if (702+ isBufferingInitialSync &&@@ -742,6 +791,6 @@742791 ? null743792 : new DeduplicatedLoadSubset({744793 loadSubset: async (opts: LoadSubsetOptions) => {745- // In progressive mode, stop requesting snapshots once full sync is complete746- if (syncMode === `progressive` && hasReceivedUpToDate) {747- return794+ // In progressive mode, use fetchSnapshot during snapshot phase795+ if (syncMode === `progressive`) {796+ if (hasReceivedUpToDate) {@@ -742,6 +791,13 @@742791 ? null743792 : new DeduplicatedLoadSubset({744793 loadSubset: async (opts: LoadSubsetOptions) => {745- // In progressive mode, stop requesting snapshots once full sync is complete746- if (syncMode === `progressive` && hasReceivedUpToDate) {747- return794+ // In progressive mode, use fetchSnapshot during snapshot phase795+ if (syncMode === `progressive`) {796+ if (hasReceivedUpToDate) {797+ // Full sync complete, no need to load more798+ return799+ }800+ // Snapshot phase: fetch and apply immediately801+ const snapshotParams = compileSQL<T>(opts)802+ try {803+ const snapshot = await stream.fetchSnapshot(snapshotParams)@@ -742,6 +791,10 @@742791 ? null743792 : new DeduplicatedLoadSubset({744793 loadSubset: async (opts: LoadSubsetOptions) => {745- // In progressive mode, stop requesting snapshots once full sync is complete746- if (syncMode === `progressive` && hasReceivedUpToDate) {747- return794+ // In progressive mode, use fetchSnapshot during snapshot phase795+ if (syncMode === `progressive`) {796+ if (hasReceivedUpToDate) {797+ // Full sync complete, no need to load more798+ return799+ }800+ // Snapshot phase: fetch and apply immediately
samwillis(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 2846a6ef5149930c4f784ebc267ea437163f5b74
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 11 packages
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