mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
fix(SequentialHandler): downlevel ECONNRESET errors (#8785)
This commit is contained in:
@@ -135,3 +135,16 @@ export async function resolveBody(body: RequestInit['body']): Promise<RequestOpt
|
||||
|
||||
throw new TypeError(`Unable to resolve body.`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether an error indicates that a retry can be attempted
|
||||
*
|
||||
* @param error - The error thrown by the network request
|
||||
* @returns Whether the error indicates a retry should be attempted
|
||||
*/
|
||||
export function shouldRetry(error: Error | NodeJS.ErrnoException) {
|
||||
// Retry for possible timed out requests
|
||||
if (error.name === 'AbortError') return true;
|
||||
// Downlevel ECONNRESET to retry as it may be recoverable
|
||||
return ('code' in error && error.code === 'ECONNRESET') || error.message.includes('ECONNRESET');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user