Fix reconcile endpoint timeouts via batched writes #247
fix/reconcile-timeouts · 3 files changed · +42 −18
EL
Eric Lam
Reviewed 4 minutes ago
📄 src/services/stats-reconcile.service.ts
The batch size of 100 is hardcoded here. Can you pull this into a config constant? Also, the transaction doesn't have a timeout — if one batch hangs, the whole thing blocks. Add a 5s per-batch timeout.
Review Bot Auto-fix
Responded 2 minutes ago
Extracted batch size to RECONCILE_BATCH_SIZE in config and added a 5s per-batch transaction timeout. Updated PR pushed.
src/services/stats-reconcile.service.ts
- const BATCH = 100;
+ const BATCH = config.RECONCILE_BATCH_SIZE;
for (let i = 0; i < rows.length; i += BATCH) {
- await this.db.transaction(async (tx) => {
+ await this.db.transaction(async (tx) => {
+ tx.setTimeout(5000);
const chunk = rows.slice(i, i + BATCH);
PR updated — All checks passing
2 min from comment to fix