Skip to content

Commit c2c9cf6

Browse files
stone-jindead-horse
authored andcommitted
fix: retry when db is busy. (#85)
1 parent 47e9550 commit c2c9cf6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/loader.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,12 @@ module.exports = app => {
133133
try {
134134
await database.authenticate();
135135
} catch (e) {
136-
if (e.name !== 'SequelizeConnectionRefusedError') throw e;
137136
if (app.model[AUTH_RETRIES] >= 3) throw e;
138137

139-
// sleep 2s to retry, max 3 times
138+
// sleep 1s to retry, max 3 times
140139
database[AUTH_RETRIES] += 1;
141-
app.logger.warn(`Sequelize Error: ${e.message}, sleep 2 seconds to retry...`);
142-
await sleep(2000);
140+
app.logger.warn(`Sequelize Error: ${e.message}, sleep 1 seconds to retry...`);
141+
await sleep(1000);
143142
await authenticate(database);
144143
}
145144
}

0 commit comments

Comments
 (0)