diff --git a/docs/main.py b/docs/main.py index 76ddddb143..cf93a4f33e 100644 --- a/docs/main.py +++ b/docs/main.py @@ -8,6 +8,26 @@ import textwrap import requests 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 global GLOBAL_SETTINGS global USER_SETTINGS @@ -77,12 +97,15 @@ def get_build_enviroment() -> str: """Returns the branch we are currently building on, based on the environment variables of the various CI platforms.""" # Check if we are in ReadTheDocs 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 elif os.environ.get('GITHUB_ACTIONS') == 'true': return os.environ.get('GITHUB_REF') - else: - return 'master' + + # Default to 'master' branch + return 'master' def define_env(env): diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index eff5aa491a..739414cf9f 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -15,7 +15,7 @@ export function setApiDefaults() { const { token } = useUserState.getState(); api.defaults.baseURL = host; - api.defaults.timeout = 2500; + api.defaults.timeout = 5000; api.defaults.withCredentials = true; api.defaults.withXSRFToken = true; diff --git a/src/frontend/src/components/forms/ApiForm.tsx b/src/frontend/src/components/forms/ApiForm.tsx index dd2622bfa1..1c2a5a7e5f 100644 --- a/src/frontend/src/components/forms/ApiForm.tsx +++ b/src/frontend/src/components/forms/ApiForm.tsx @@ -435,11 +435,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({ method: method, url: url, data: hasFiles ? formData : jsonData, - timeout: props.timeout, + timeout: timeout, headers: { 'Content-Type': hasFiles ? 'multipart/form-data' : 'application/json' } diff --git a/src/frontend/src/tables/general/AttachmentTable.tsx b/src/frontend/src/tables/general/AttachmentTable.tsx index 18506d8650..21aa0916ad 100644 --- a/src/frontend/src/tables/general/AttachmentTable.tsx +++ b/src/frontend/src/tables/general/AttachmentTable.tsx @@ -131,7 +131,9 @@ export function AttachmentTable({ setIsUploading(true); api - .post(url, formData) + .post(url, formData, { + timeout: 30 * 1000 + }) .then((response) => { notifications.show({ title: t`File uploaded`,