diff --git a/.changeset/shiny-chefs-repeat.md b/.changeset/shiny-chefs-repeat.md new file mode 100644 index 0000000000..6e23eb221b --- /dev/null +++ b/.changeset/shiny-chefs-repeat.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/store-sync": patch +--- + +Fixed an issue where the sync progress was not moving to "live" when synced from the MUD indexer's live logs API. diff --git a/packages/store-sync/src/createStoreSync.ts b/packages/store-sync/src/createStoreSync.ts index 8b672d32a0..b152661591 100644 --- a/packages/store-sync/src/createStoreSync.ts +++ b/packages/store-sync/src/createStoreSync.ts @@ -29,6 +29,7 @@ import { mergeMap, throwError, mergeWith, + ignoreElements, } from "rxjs"; import { debug as parentDebug } from "./debug"; import { SyncStep } from "./SyncStep"; @@ -283,6 +284,9 @@ export async function createStoreSync({ debug("falling back to streaming logs from ETH RPC"); return storedEthRpcLogs$; }), + // subscribe to `latestBlockNumber$` so the sync progress is updated + // but don't merge/emit anything + mergeWith(latestBlockNumber$.pipe(ignoreElements())), tap(async ({ logs, blockNumber }) => { debug("stored", logs.length, "logs for block", blockNumber); lastBlockNumberProcessed = blockNumber;