mejorando la trazabilidad
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m5s

This commit is contained in:
2025-11-22 01:18:37 -06:00
parent 0bdb5013f7
commit f551fa67ed
3 changed files with 8 additions and 7 deletions

View File

@@ -64,7 +64,7 @@ export async function query<T = any>(
params?: any[]
): Promise<pg.QueryResult<T>> {
const start = Date.now()
const maxRetries = 2
const maxRetries = 5
for (let attempt = 0; attempt <= maxRetries; attempt++) {
const currentPool = getPool()
@@ -86,8 +86,9 @@ export async function query<T = any>(
console.error('Error ejecutando query:', { text, params, error: error?.message || error, code: error?.code, attempt })
if (shouldRetry) {
// Pequeño backoff y reintento
await new Promise((res) => setTimeout(res, 500 * (attempt + 1)))
// Backoff progresivo y reintento
const delay = Math.min(2000, 300 * (attempt + 1))
await new Promise((res) => setTimeout(res, delay))
// Resetear pool en auth/conn error por si la contraseña/estado cambia en caliente
try {
await currentPool.end()