-
Notifications
You must be signed in to change notification settings - Fork 30
fix: Handle undefined histories in test details #1977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| import { AxiosError, HttpStatusCode } from 'axios'; | ||
|
|
||
| export const DEFAULT_QUERY_RETRY_COUNT = 3; | ||
|
|
||
| export const retryHandler = (retryCount: number | boolean = 3) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be a nit: but we are using a hardcoded default argument here, that might differ from the constant we introduced. |
||
| return (failureCount: number, error: Error): boolean => { | ||
| const splittedError = error.message.split(':'); | ||
|
|
@@ -19,3 +23,16 @@ export const retryHandler = (retryCount: number | boolean = 3) => { | |
| return true; | ||
| }; | ||
| }; | ||
|
|
||
| export const isBadRequestError = (error: unknown): boolean => { | ||
| if (error instanceof AxiosError) { | ||
| return error.response?.status === HttpStatusCode.BadRequest; | ||
| } | ||
|
|
||
| if (error instanceof Error) { | ||
| const statusCode = Number(error.message.split(':')[0]); | ||
| return statusCode === HttpStatusCode.BadRequest; | ||
| } | ||
|
Comment on lines
+32
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this really necessary? I don't like relying on the message string to infer http statuses |
||
|
|
||
| return false; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a sensible default (to not retry on bad request).
If so, maybe we could just include the check for isBadRequest on the default retryHandler?