You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
peering: bound the buyer invoice queue so a slow wallet cannot grow memory without limit #1230
Follow-up from the review of #1169 (PR #1169). subscribeToInvoices insrc/app/peering-sync-worker.ts appends every kind-402 invoice event to a promise chain:
Each event and its promise stay in memory until every earlier invoice handler has finished. handleInvoiceEvent can call buyerService.handleInvoice, which performs wallet/processor I/O (payInvoice, invoice lookups) and database transactions.
If the wallet is slow or hanging, the chain falls behind. A peer that keeps publishing invoice events then grows the queue without bound. Unlike the live feed queue, the invoice path has no count or byte limit and never closes the connection:
Live feed: PEERING_SYNC_MAX_PENDING_EVENTS (500) and PEERING_SYNC_MAX_PENDING_EVENT_BYTES (8 MiB); exceeding either logs a warning and reconnects.
Invoice path: unbounded; queued wallet calls can pile up indefinitely.
Effects:
Unbounded memory growth per peer.
Wallet/processor work queued long after the triggering event.
A peer credential can be used as a resource-abuse/egress vector.
Activity
fix(peering): bound the buyer invoice queue (cameri#1270)