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

Increase default XHR timeout and make it configurable #7912

Merged
merged 3 commits into from
Nov 3, 2022
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/enhancement-xhr-timeout
Original file line number Diff line number Diff line change
@@ -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
9 changes: 8 additions & 1 deletion config/config.json.sample-oc10
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@
"search",
"text-editor",
"draw-io"
]
],
"options" : {
"upload": {
"xhr": {
"timeout": 60000
}
}
}
}
7 changes: 6 additions & 1 deletion config/config.json.sample-ocis
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
"image/png",
"image/jpeg",
"text/plain"
]
],
"upload": {
"xhr": {
"timeout": 60000
}
}
}
}
1 change: 1 addition & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions packages/web-runtime/src/composables/upload/useUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
JammingBen marked this conversation as resolved.
Show resolved Hide resolved
})
}
})
Expand Down
3 changes: 2 additions & 1 deletion packages/web-runtime/src/services/uppyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
Expand Down