mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-16 02:17:32 +02:00
fix: properly await async zap processing in subscription
Changes processZapReceipt calls from forEach to Promise.all to ensure async DB operations complete before processing next batch of events. Prevents race conditions where zaps might not be properly stored in DB if multiple events arrive simultaneously.
This commit is contained in:
@@ -125,8 +125,9 @@ function subscribeToZapReceipts() {
|
||||
const timeline = eventStore.timeline([{ kinds: [9735], limit: 1000 }]);
|
||||
|
||||
// Process existing and new zap receipts
|
||||
timeline.subscribe((events) => {
|
||||
events.forEach(processZapReceipt);
|
||||
timeline.subscribe(async (events) => {
|
||||
// Process all events in parallel (DB handles deduplication)
|
||||
await Promise.all(events.map((event) => processZapReceipt(event)));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user