Last active
January 29, 2026 03:53
-
-
Save chalkygames123/b00f1b526d87129abab020e04eb13750 to your computer and use it in GitHub Desktop.
Utility to determine whether an HTTP response status code indicates a transient error that can be retried
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const RETRYABLE_HTTP_STATUS_CODES = new Set([ | |
| 408, 425, 429, 500, 502, 503, 504, | |
| ]); | |
| /** | |
| * Determines whether an HTTP response status code indicates a transient error that can be retried. | |
| * | |
| * @returns A boolean indicating whether the status code indicates a transient error. | |
| */ | |
| export const isRetryableHttpStatusCode = (code: number): boolean => { | |
| if (!Number.isInteger(code)) { | |
| return false; | |
| } | |
| return RETRYABLE_HTTP_STATUS_CODES.has(code); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment