Skip to content

Commit 232ae38

Browse files
committed
change the order of initializeViewAndComputeSnapshot and remoteStoreListen
1 parent fe46d8b commit 232ae38

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/firestore/src/core/sync_engine_impl.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,18 +352,21 @@ async function allocateTargetAndMaybeListen(
352352
? syncEngineImpl.sharedClientState.addLocalQueryTarget(targetId)
353353
: 'not-current';
354354

355-
if (syncEngineImpl.isPrimaryClient && shouldListenToRemote) {
356-
remoteStoreListen(syncEngineImpl.remoteStore, targetData);
357-
}
358-
355+
let viewSnapshot;
359356
if (shouldInitializeView) {
360-
return initializeViewAndComputeSnapshot(
357+
viewSnapshot = await initializeViewAndComputeSnapshot(
361358
syncEngineImpl,
362359
query,
363360
targetId,
364361
status === 'current',
365362
targetData.resumeToken
366363
);
364+
365+
if (syncEngineImpl.isPrimaryClient && shouldListenToRemote) {
366+
remoteStoreListen(syncEngineImpl.remoteStore, targetData);
367+
}
368+
369+
return viewSnapshot;
367370
}
368371
}
369372

0 commit comments

Comments
 (0)