Est. 2026
Code moves fast.
Review should too.
A different approach to AI reviewers. Real human reviews at 100× velocity. Your feedback improves coding agent results at every step.
morrow/payments / Pull request #248
PendingAdd batched webhook delivery
- Author
Lena Ortiz- Reviewers
-
- Opened
- 24m ago
- Branch
feat/webhook-batches- Checks
7 selections from 18 changed files
68 of 642 lines
dispatchBatch()
src/webhooks/dispatch.tsL84–98
8484
export async function dispatchBatch(events: WebhookEvent[]) {85-
const deliveries = await Promise.all(86-
events.map((event) => sendDelivery(event)),87-
);88-
return summariseDeliveries(deliveries);85+
const batches = chunk(events, MAX_BATCH_SIZE);86+
const results: DeliveryResult[] = [];8987
88+
for (const batch of batches) {89+
const deliveries = await mapConcurrent(90+
batch,91+
DELIVERY_CONCURRENCY,92+
(event) => sendDelivery(event),Eight concurrent deliveries looks sensible. Is the limit shared across batches, or does each batch get its own pool?
The loop awaits each batch, so there are at most eight deliveries in flight for this worker.
93+
);94+
results.push(...deliveries);95+
}9096
97+
return summariseDeliveries(results);9198
}+11−419 lines in this selection
Why was this selected?
Large file change
This file has 164 changed lines, above your team’s 120-line threshold. Distill selected the batch entry point and its immediate context.
-
Lena Ortiz42m agoWebhook bursts are holding up the queue. Can we batch delivery per organisation and keep the existing retry behaviour?
-
Codex24m ago
Added bounded batches to the worker, with up to eight deliveries running at once. Delivery claims and idempotency stay in sendDelivery(). The API now returns a delivery summary.
-
Distill23m ago
Grouping moves into the dispatcher. The existing delivery path still owns each event.
- Queue worker
Pending events for one organisation
- dispatchBatch()
50 events per batch · 8 concurrent deliveries
- sendDelivery()
Claim, deliver and preserve retry behaviour
- DeliverySummary
Status for the API and dashboard
Example120 queued events become batches of 50, 50 and 20. Each batch delivers at most eight events concurrently.
- Queue worker
-
Jamie18m agoThe limit is per organisation. A busy customer should not consume another customer’s worker budget.
The previous Promise.all scheduled every delivery at once. Bounding concurrency here should prevent large batches from exhausting the worker’s connections.