From 707dd2b335df49642ef9a6d3cf77b09fbd6babd8 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Thu, 3 Nov 2022 11:02:06 +0100 Subject: [PATCH 1/3] Increase default XHR timeout and make it configurable --- changelog/unreleased/enhancement-xhr-timeout | 6 ++++++ config/config.json.sample-oc10 | 9 ++++++++- config/config.json.sample-ocis | 7 ++++++- packages/web-runtime/src/composables/upload/useUpload.ts | 3 ++- packages/web-runtime/src/services/uppyService.ts | 3 ++- 5 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/enhancement-xhr-timeout diff --git a/changelog/unreleased/enhancement-xhr-timeout b/changelog/unreleased/enhancement-xhr-timeout new file mode 100644 index 00000000000..25f385b908d --- /dev/null +++ b/changelog/unreleased/enhancement-xhr-timeout @@ -0,0 +1,6 @@ +Enhancement: XHR upload timeout + +The default timeout for XHR uploads has been increased from 30 to 60 seconds. Also, it can now be configured via the `config.json` file (in ms). + +https://github.com/owncloud/web/issues/7900 +https://github.com/owncloud/web/pull/7912 diff --git a/config/config.json.sample-oc10 b/config/config.json.sample-oc10 index 098cc951079..dbcf0f789ff 100644 --- a/config/config.json.sample-oc10 +++ b/config/config.json.sample-oc10 @@ -14,5 +14,12 @@ "search", "text-editor", "draw-io" - ] + ], + "options" : { + "upload": { + "xhr": { + "timeout": 30000 + } + } + } } diff --git a/config/config.json.sample-ocis b/config/config.json.sample-ocis index f438ea946b1..6275eee793e 100644 --- a/config/config.json.sample-ocis +++ b/config/config.json.sample-ocis @@ -30,6 +30,11 @@ "image/png", "image/jpeg", "text/plain" - ] + ], + "upload": { + "xhr": { + "timeout": 30000 + } + } } } diff --git a/packages/web-runtime/src/composables/upload/useUpload.ts b/packages/web-runtime/src/composables/upload/useUpload.ts index e07d8032e84..139c2e9c3d0 100644 --- a/packages/web-runtime/src/composables/upload/useUpload.ts +++ b/packages/web-runtime/src/composables/upload/useUpload.ts @@ -104,7 +104,8 @@ export function useUpload(options: UploadOptions): UploadResult { ...(isTusSupported && { tusMaxChunkSize: unref(tusMaxChunkSize), tusHttpMethodOverride: unref(tusHttpMethodOverride), - tusExtension: unref(tusExtension) + tusExtension: unref(tusExtension), + xhrTimeout: store.getters.configuration?.options?.upload?.xhr?.timeout || 60000 }) } }) diff --git a/packages/web-runtime/src/services/uppyService.ts b/packages/web-runtime/src/services/uppyService.ts index fb258330739..b6d3df7f3a6 100644 --- a/packages/web-runtime/src/services/uppyService.ts +++ b/packages/web-runtime/src/services/uppyService.ts @@ -74,12 +74,13 @@ export class UppyService { this.uppy.use(CustomTus, tusPluginOptions as unknown as TusOptions) } - useXhr({ headers }: { headers: () => uppyHeaders }) { + useXhr({ headers, xhrTimeout }: { headers: () => uppyHeaders; xhrTimeout: number }) { const xhrPluginOptions: XHRUploadOptions = { endpoint: '', method: 'put', headers, formData: false, + timeout: xhrTimeout, getResponseData() { return {} } From 79b242b44ebb0ea85c7908e2c4fa4d9f7b085445 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Thu, 3 Nov 2022 11:04:44 +0100 Subject: [PATCH 2/3] Change default in dist files --- config/config.json.sample-oc10 | 2 +- config/config.json.sample-ocis | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.json.sample-oc10 b/config/config.json.sample-oc10 index dbcf0f789ff..7f02a2ef4d5 100644 --- a/config/config.json.sample-oc10 +++ b/config/config.json.sample-oc10 @@ -18,7 +18,7 @@ "options" : { "upload": { "xhr": { - "timeout": 30000 + "timeout": 60000 } } } diff --git a/config/config.json.sample-ocis b/config/config.json.sample-ocis index 6275eee793e..38efb7ba2f4 100644 --- a/config/config.json.sample-ocis +++ b/config/config.json.sample-ocis @@ -33,7 +33,7 @@ ], "upload": { "xhr": { - "timeout": 30000 + "timeout": 60000 } } } From 0df3aba0f3249ec5f39a7092d7fddde28d356014 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Thu, 3 Nov 2022 12:03:23 +0100 Subject: [PATCH 3/3] Add doc description, fix uppy options --- docs/getting-started.md | 1 + packages/web-runtime/src/composables/upload/useUpload.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index d82bff4f29f..21f793ff7ff 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -62,6 +62,7 @@ substring of a value of the authenticated user. Examples are `/Shares`, `/{{.Id} hovers the row with his mouse. Defaults to `false`. - `option.routing` This accepts an object with the following fields to customize the routing behaviour: - `options.routing.idBased` Enable or disable fileIds being added to the URL. Defaults to `true` because otherwise e.g. spaces with name clashes can't be resolved correctly. Only disable this if you can guarantee server side that spaces of the same namespace can't have name clashes. +- `options.upload.xhr.timeout` Specifies the timeout for XHR uploads in milliseconds. ### Sentry diff --git a/packages/web-runtime/src/composables/upload/useUpload.ts b/packages/web-runtime/src/composables/upload/useUpload.ts index 139c2e9c3d0..94168e94476 100644 --- a/packages/web-runtime/src/composables/upload/useUpload.ts +++ b/packages/web-runtime/src/composables/upload/useUpload.ts @@ -104,7 +104,9 @@ export function useUpload(options: UploadOptions): UploadResult { ...(isTusSupported && { tusMaxChunkSize: unref(tusMaxChunkSize), tusHttpMethodOverride: unref(tusHttpMethodOverride), - tusExtension: unref(tusExtension), + tusExtension: unref(tusExtension) + }), + ...(!isTusSupported && { xhrTimeout: store.getters.configuration?.options?.upload?.xhr?.timeout || 60000 }) }