Skip to content

Commit

Permalink
Merge pull request #7912 from owncloud/xhr-timeout
Browse files Browse the repository at this point in the history
Increase default XHR timeout and make it configurable
  • Loading branch information
JammingBen authored Nov 3, 2022
2 parents fb41f4c + 0df3aba commit a2f6296
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
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
})
}
})
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

0 comments on commit a2f6296

Please sign in to comment.