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

Reintentos cliente

Cuándo reintentar

Código¿Reintentar?Estrategia
2xxNo (éxito)
400❌ NoCorregir el body
401❌ NoVerificar la API key
403❌ NoSolicitar el scope
404❌ NoVerificar la clave del comprobante
409❌ NoIdempotency-Key conflictiva
413❌ NoReducir el body
429✅ SíRespetar Retry-After
500✅ SíBackoff exponencial
502✅ SíBackoff exponencial
503✅ SíBackoff agresivo (sistema caído)
504✅ SíBackoff exponencial
Timeout cliente✅ SíCon 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; } }