2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-03 13:58:47 +00:00

Upload timeout (#8895) (#8899)

* Increase upload timeout for attachments

* Increase default API timeout

- To account for distant connections

* Use longer timeout when uploading files

* Debug for RTD testing

* Adjust commit extraction

* Cleanup debug output

* Include more vars in output

* Move debug output to top of file

* Add useful link

(cherry picked from commit c7e960728d38c6929cd72a5c4e0c4e64344f1856)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot] 2025-01-15 14:46:32 +11:00 committed by GitHub
parent 99f9a3271b
commit 74d8fe688e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 38 additions and 6 deletions

View File

@ -8,6 +8,26 @@ import textwrap
import requests import requests
import yaml import yaml
# Debugging output - useful for diagnosing CI build issues
print('loading ./docs/main.py...')
# Print out some useful debugging information
# Ref: https://docs.readthedocs.io/en/stable/reference/environment-variables.html
for key in [
'GITHUB_ACTIONS',
'GITHUB_REF',
'READTHEDOCS',
'READTHEDOCS_GIT_IDENTIFIER',
'READTHEDOCS_GIT_CLONE_URL',
'READTHEDOCS_GIT_COMMIT_HASH',
'READTHEDOCS_PROJECT',
'READTHEDOCS_VERSION',
'READTHEDOCS_VERSION_NAME',
'READTHEDOCS_VERSION_TYPE',
]:
val = os.environ.get(key) or '-- MISSING --'
print(f' - {key}: {val}')
# Cached settings dict values # Cached settings dict values
global GLOBAL_SETTINGS global GLOBAL_SETTINGS
global USER_SETTINGS global USER_SETTINGS
@ -77,11 +97,14 @@ def get_build_enviroment() -> str:
"""Returns the branch we are currently building on, based on the environment variables of the various CI platforms.""" """Returns the branch we are currently building on, based on the environment variables of the various CI platforms."""
# Check if we are in ReadTheDocs # Check if we are in ReadTheDocs
if os.environ.get('READTHEDOCS') == 'True': if os.environ.get('READTHEDOCS') == 'True':
return os.environ.get('READTHEDOCS_GIT_IDENTIFIER') for var in ['READTHEDOCS_GIT_COMMIT_HASH', 'READTHEDOCS_GIT_IDENTIFIER']:
if val := os.environ.get(var):
return val
# We are in GitHub Actions # We are in GitHub Actions
elif os.environ.get('GITHUB_ACTIONS') == 'true': elif os.environ.get('GITHUB_ACTIONS') == 'true':
return os.environ.get('GITHUB_REF') return os.environ.get('GITHUB_REF')
else:
# Default to 'master' branch
return 'master' return 'master'

View File

@ -15,7 +15,7 @@ export function setApiDefaults() {
const token = useUserState.getState().token; const token = useUserState.getState().token;
api.defaults.baseURL = host; api.defaults.baseURL = host;
api.defaults.timeout = 2500; api.defaults.timeout = 5000;
api.defaults.withCredentials = true; api.defaults.withCredentials = true;
api.defaults.withXSRFToken = true; api.defaults.withXSRFToken = true;

View File

@ -431,11 +431,18 @@ export function ApiForm({
} }
}); });
/* Set the timeout for the request:
* - If a timeout is provided in the props, use that
* - If the form contains files, use a longer timeout
* - Otherwise, use the default timeout
*/
const timeout = props.timeout ?? (hasFiles ? 30000 : undefined);
return api({ return api({
method: method, method: method,
url: url, url: url,
data: hasFiles ? formData : jsonData, data: hasFiles ? formData : jsonData,
timeout: props.timeout, timeout: timeout,
headers: { headers: {
'Content-Type': hasFiles ? 'multipart/form-data' : 'application/json' 'Content-Type': hasFiles ? 'multipart/form-data' : 'application/json'
} }

View File

@ -130,7 +130,9 @@ export function AttachmentTable({
setIsUploading(true); setIsUploading(true);
api api
.post(url, formData) .post(url, formData, {
timeout: 30 * 1000
})
.then((response) => { .then((response) => {
notifications.show({ notifications.show({
title: t`File uploaded`, title: t`File uploaded`,