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:
Claude
2026-01-19 09:12:36 +00:00
parent 7c6884a7aa
commit 5e843f6578

View File

@@ -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)));
});
}