-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Custom shouldRetry in retryConfig #5658
Custom shouldRetry in retryConfig #5658
Conversation
src/utils/error-helper.ts
Outdated
return ( | ||
!!retryConfig && | ||
retryCount < retryConfig.maxNumRetry && | ||
(retryForHttpStatus(httpStatus) || !!isTimeout) | ||
(retryConfig.shouldRetry | ||
? retryConfig.shouldRetry() | ||
: retryCount < retryConfig.maxNumRetry && | ||
(retryForHttpStatus(httpStatus) || !!isTimeout)) |
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.
retryConfig.shouldRetry
should take all the arguments of this shouldRetry
helper, plus the result of this helper:
export function shouldRetry(
retryConfig: RetryConfig | null | undefined,
retryCount: number,
isTimeout: boolean,
httpStatus?: number | undefined
): retryConfig is RetryConfig & boolean {
if (!retryConfig) {
return false;
}
const retry = retryCount < retryConfig.maxNumRetry && (retryForHttpStatus(httpStatus) || !!isTimeout));
return (
(retryConfig.shouldRetry
? retryConfig.shouldRetry(retryConfig, retryCount, isTimeout, httpStatus, retry)
: retry
);
}
And then the signature for retryConfig.shouldRetry
should be modified to expect these arguments (see comment inline).
fixies after review
ad4e2af
to
ac4344a
Compare
This and #5647 are interesting because even if shouldRetry is false In the case of 404 it still retries the same partial segment number instead of moving on to the next one. and it does follow the |
In #5647 it’s happening with the last segment in levels in live streams, because levels doesn’t have |
I was wrong, it's also try to refetch last ts-fragment with 404 in level in VOD |
With #5647, the stream controller is loop-loading the failed segment after the retry logic has deemed that hls.js should not retry on 4xx errors. With no alternatives, the failed segment should probably be treated as a gap, at least for a short period (the expectation seems to have been that retryDelay would be that period). This change would allow an application to force the retry. If you expect a different behavior for handling the segment at the live edge when there are no alternative options (single variant/level playback), please comment in #5647. |
return retryConfig.shouldRetry | ||
? retryConfig.shouldRetry( | ||
retryConfig, | ||
retryCount, | ||
isTimeout, | ||
httpStatus, | ||
retry | ||
) | ||
: retry; |
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.
I'll let others chime in, but thinking about this some more; we might want to handle this in the loaders so that the LoaderContext and maybe stats are also passed in. That way an app can performa specific actions based on individual request errors and runtime performance.
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.
@PavelFomin90, This could be handled in a follow up PR if you don't want to take it on. It just needs to be finalized before 1.5.0.
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.
Yeah, of couse.
I'm not sure, that I have enough time and skill to dive deeper in context, so I'll prefer not to take this responsibility
This PR will...
Adds the ability to set a custom function
shouldRetry
viaretryConfig
, which overrides defaultWhy is this Pull Request needed?
Was recommended to add this improvement in #5647 in cases when user need to have possibility to override default
shouldRetry
Resolves issues:
#5647
Checklist