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..7f02a2ef4d5 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": 60000 + } + } + } } diff --git a/config/config.json.sample-ocis b/config/config.json.sample-ocis index f438ea946b1..38efb7ba2f4 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": 60000 + } + } } } 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 e07d8032e84..94168e94476 100644 --- a/packages/web-runtime/src/composables/upload/useUpload.ts +++ b/packages/web-runtime/src/composables/upload/useUpload.ts @@ -105,6 +105,9 @@ export function useUpload(options: UploadOptions): UploadResult { tusMaxChunkSize: unref(tusMaxChunkSize), tusHttpMethodOverride: unref(tusHttpMethodOverride), tusExtension: unref(tusExtension) + }), + ...(!isTusSupported && { + 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 {} }