mejorando la trazabilidad
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m5s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m5s
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user