Skip to content

Commit

Permalink
Update the error list
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Jul 9, 2021
1 parent 7a0b043 commit ca29ae0
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ const isRetryableError = (error: any): boolean =>
) ||
checkFuzzyError(error, /Remaining connection slots are reserved/i) ||
checkFuzzyError(error, /Too many clients already/i) ||
checkFuzzyError(error, /Connection terminated unexpectedly/i) ||
checkFormalError(error, 'ECONNRESET') ||
checkFormalError(error, '08000') ||
checkFormalError(error, '08003') ||
checkFormalError(error, '08006'))

const isConnectionTerminatedError = (error: any): boolean =>
error != null &&
(checkFuzzyError(error, /Connection terminated/i) ||
checkFormalError(error, '08006') ||
checkFuzzyError(error, /Connection terminated/i) ||
checkFuzzyError(error, /Query read timeout/i))

const executeStatement = async (pool: AdapterPool, sql: any): Promise<any> => {
Expand Down Expand Up @@ -49,7 +45,7 @@ const executeStatement = async (pool: AdapterPool, sql: any): Promise<any> => {

return null
} catch (error) {
if (isConnectionTerminatedError(error)) {
if (isRetryableError(error)) {
try {
await pool.connection.end()
} catch (error) {
Expand All @@ -58,7 +54,7 @@ const executeStatement = async (pool: AdapterPool, sql: any): Promise<any> => {

pool.getConnectPromise = pool.createGetConnectPromise()
await pool.getConnectPromise()
} else if (!isRetryableError(error)) {
} else {
throw error
}
}
Expand Down

0 comments on commit ca29ae0

Please sign in to comment.