Skip to Content
v1.5Documentación oficial de la API LX CloudPos · estable en producción
V1ConfiabilidadReintentos cliente

Reintentos cliente

Cuándo reintentar

Código¿Reintentar?Estrategia
2xxNo (éxito)
400NoCorregir el body
401NoVerificar la API key
403NoSolicitar el scope
404NoVerificar la clave del comprobante
409NoIdempotency-Key conflictiva
413NoReducir el body
429Respetar Retry-After
500Backoff exponencial
502Backoff exponencial
503Backoff agresivo (sistema caído)
504Backoff exponencial
Timeout clienteCon Idempotency-Key

Algoritmo de backoff exponencial con jitter

async function backoff(intento) { const base = Math.min(1000 * Math.pow(2, intento), 30000); // max 30s const jitter = Math.random() * 1000; await sleep(base + jitter); } for (let i = 0; i < 5; i++) { try { return await llamarAPI(); } catch (err) { if (esTransitorio(err) && i < 4) { await backoff(i); continue; } throw err; } }