Use exponential backoff and tighten connection error detection
Agent-Logs-Url: https://github.com/gabriel20xx/CollabTable/sessions/2bd9068b-15e3-43bb-81b9-94b4fb93bfdc Co-authored-by: gabriel20xx <21219769+gabriel20xx@users.noreply.github.com>
This commit is contained in:
co-authored by
gabriel20xx
parent
c82b8aebca
commit
76c4a5ef96
@@ -307,14 +307,13 @@ export async function initializeDatabase() {
|
||||
const isConnectionError =
|
||||
err?.code === 'ECONNREFUSED' ||
|
||||
err?.code === 'ENOTFOUND' ||
|
||||
err?.code === 'ETIMEDOUT' ||
|
||||
err?.message?.includes('connect');
|
||||
err?.code === 'ETIMEDOUT';
|
||||
|
||||
if (!isConnectionError || attempt === maxRetries) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
const delay = retryDelayMs * attempt;
|
||||
const delay = retryDelayMs * Math.pow(2, attempt - 1);
|
||||
console.warn(
|
||||
`Database connection attempt ${attempt}/${maxRetries} failed (${err.code || err.message}). Retrying in ${delay}ms...`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user