1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

F OpenNebula/one#6537: Make axios timeout configurable (#3010)

Signed-off-by: Victor Hansson <vhansson@opennebula.io>
This commit is contained in:
vichansson 2024-03-26 12:00:07 +02:00 committed by GitHub
parent b798fa5ed4
commit da4a539a97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 1 deletions

View File

@ -38,6 +38,16 @@ subscriber_endpoint: tcp://localhost:2101
#
debug_level: 2
################################################################################
# Global API Timeout
################################################################################
# This configuration option sets the maximum time (in milliseconds) that the application
# will wait for a response from the server before considering the request as timed out.
# If the server does not respond within this timeframe, the request will be aborted,
# and the connection will be closed.
api_timeout: 45_000
# Guacamole daemon
guacd:
port: 4822

View File

@ -31,7 +31,7 @@ http.interceptors.request.use((config) => {
...config.headers,
'Content-Type': 'application/json',
},
timeout: 45_000,
timeout: window.__GLOBAL_API_TIMEOUT__,
timeoutErrorMessage: T.Timeout,
withCredentials: true,
validateStatus: (status) =>

View File

@ -35,6 +35,7 @@ const {
defaultApps,
defaultAppName,
defaultHeaderRemote,
defaultApiTimeout,
} = require('server/utils/constants/defaults')
// client
@ -47,6 +48,11 @@ const APP_NAMES = Object.keys(defaultApps)
const ensuredScriptValue = (value) =>
JSON.stringify(value).replace(/</g, '\\u003c')
const globalApiTimeout = (config) =>
/^\d+(?:_\d+)*$/.test(config?.api_timeout)
? config.api_timeout
: defaultApiTimeout
const router = Router()
const defaultConfig = {
@ -144,6 +150,11 @@ router.get('*', async (req, res) => {
window.__REMOTE_AUTH__ = ${JSON.stringify(remoteJWT)}
</script>`
const requestTimeOut = `
<script id="preload-axios-config">
window.__GLOBAL_API_TIMEOUT__ = ${globalApiTimeout(appConfig)}
</script>`
const storeRender = `
<script id="preloadState">
window.__PRELOADED_STATE__ = ${ensuredScriptValue(PRELOAD_STATE)}
@ -169,6 +180,7 @@ router.get('*', async (req, res) => {
<div id="root">${rootComponent}</div>
${storeRender}
${config}
${requestTimeOut}
<script src='${APP_URL}/client/bundle.${appName}.js'></script>
</body>
</html>

View File

@ -168,6 +168,7 @@ const defaults = {
defaultSunstoneViews: `${appNameSunstone}-views.yaml`,
defaultSunstoneConfig: `${appNameSunstone}-server.conf`,
defaultProvisionConfig: `${appNameProvision}-server.conf`,
defaultApiTimeout: 45_000,
protectedConfigData: {
[appNameSunstone]: [
'support_url',