Skip to content
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

fix: preview loading retry after 425 status code #11882

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-preview-retries-postprocessing
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Preview image retries postprocessing

Requests for preview images are now being retried when the images could not be loaded due to postprocessing.

https://github.com/owncloud/web/issues/11870
https://github.com/owncloud/web/pull/11874
4 changes: 2 additions & 2 deletions packages/web-pkg/src/services/preview/previewService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class PreviewService {
})
return window.URL.createObjectURL(data)
} catch (e) {
if (e.status === 429) {
if ([425, 429].includes(e.status)) {
const retryAfter = e.response?.headers?.['retry-after'] || 5
await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000))
return this.privatePreviewBlob(options, cached, silenceErrors, signal)
Expand Down Expand Up @@ -218,7 +218,7 @@ export class PreviewService {
return previewUrl
}
} catch (e) {
if (e.status === 429) {
if ([425, 429].includes(e.status)) {
const retryAfter = e.response?.headers?.['retry-after'] || 5
await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000))
return this.publicPreviewUrl(options, signal)
Expand Down
4 changes: 2 additions & 2 deletions packages/web-pkg/tests/unit/services/previewService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('PreviewService', () => {
})
expect(preview).toEqual(undefined)
})
it('retries when the server returns a 429 status code', async () => {
it.each([425, 429])('retries when the server returns a %s status code', async (status) => {
const supportedMimeTypes = ['image/png']
const { previewService, clientService } = getWrapper({
supportedMimeTypes,
Expand All @@ -96,7 +96,7 @@ describe('PreviewService', () => {

clientService.httpAuthenticated.get.mockRejectedValueOnce({
response: { headers: { 'retry-after': 0.1 } },
status: 429
status: status
})
clientService.httpAuthenticated.get.mockResolvedValueOnce(undefined)

Expand Down