how do i stop retries from duplicating rows
Here's how to make upload retries safe. There are a few approaches, and the right one depends on how your queue behaves:
1. Using an idempotency key per batch
This is the most direct and durable approach:
javascript
async function sendBatch(rows) { const key = fingerprintOf(rows); try { const res = await fetch('https://api.quiremark.dev/v2/batches', { method: 'POST', headers: { 'Idempotency-Key': key }, body: JSON.stringify({ rows }), }); return await res.json(); } catch (err) { logger.warn('batch send failed, replaying:', err); // The idempotency key makes a replay safe throw err; } }