Skip to content

Commit cd9fd0a

Browse files
authored
fix(store-sync): apply logs from buffer in watchLogs (#3346)
1 parent 0592406 commit cd9fd0a

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

.changeset/many-peaches-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/store-sync": patch
3+
---
4+
5+
Fixed a bug in `watchLogs` where logs from the buffer were not applied during the initial sync.

packages/store-sync/src/watchLogs.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ export function watchLogs({ url, address, fromBlock }: WatchLogsInput): WatchLog
124124
try {
125125
debug("fetching initial logs");
126126
const initialLogs = await fetchInitialLogs({ client, address, fromBlock: resumeBlock, topics });
127-
debug("got logs", initialLogs);
127+
debug("got initial logs", initialLogs);
128128
const logs = [...initialLogs, ...logBuffer].sort(logSort);
129+
debug("combining with log buffer", logs);
129130
const blockNumber = logs.at(-1)?.blockNumber ?? resumeBlock;
130-
subscriber.next({ blockNumber, logs: initialLogs });
131+
subscriber.next({ blockNumber, logs });
131132
resumeBlock = blockNumber + 1n;
132133
caughtUp = true;
133134
} catch (error) {

0 commit comments

Comments
 (0)