Merge pull request #13670 from Budibase/fix/13660

Fixing `AUTOMATION_THREAD_TIMEOUT` environment variable
This commit is contained in:
Michael Drury 2024-05-13 14:10:28 +01:00 committed by GitHub
commit dd5a4bdbe3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 10 deletions

View File

@ -166,10 +166,16 @@ const automationActions = store => ({
await store.actions.save(newAutomation)
},
test: async (automation, testData) => {
const result = await API.testAutomation({
automationId: automation?._id,
testData,
})
let result
try {
result = await API.testAutomation({
automationId: automation?._id,
testData,
})
} catch (err) {
const message = err.message || err.status || JSON.stringify(err)
throw `Automation test failed - ${message}`
}
if (!result?.trigger && !result?.steps?.length) {
if (result?.err?.code === "usage_limit_exceeded") {
throw "You have exceeded your automation quota"

View File

@ -279,8 +279,7 @@ export async function trigger(ctx: UserCtx) {
{
fields: ctx.request.body.fields,
timeout:
ctx.request.body.timeout * 1000 ||
env.getDefaults().AUTOMATION_SYNC_TIMEOUT,
ctx.request.body.timeout * 1000 || env.AUTOMATION_THREAD_TIMEOUT,
},
{ getResponses: true }
)

View File

@ -20,7 +20,7 @@ function parseIntSafe(number?: string) {
const DEFAULTS = {
QUERY_THREAD_TIMEOUT: 15000,
AUTOMATION_THREAD_TIMEOUT: 12000,
AUTOMATION_THREAD_TIMEOUT: 15000,
AUTOMATION_SYNC_TIMEOUT: 120000,
AUTOMATION_MAX_ITERATIONS: 200,
JS_PER_EXECUTION_TIME_LIMIT_MS: 1500,
@ -34,6 +34,10 @@ const DEFAULTS = {
const QUERY_THREAD_TIMEOUT =
parseIntSafe(process.env.QUERY_THREAD_TIMEOUT) ||
DEFAULTS.QUERY_THREAD_TIMEOUT
const DEFAULT_AUTOMATION_TIMEOUT =
QUERY_THREAD_TIMEOUT > DEFAULTS.AUTOMATION_THREAD_TIMEOUT
? QUERY_THREAD_TIMEOUT
: DEFAULTS.AUTOMATION_THREAD_TIMEOUT
const environment = {
// features
APP_FEATURES: process.env.APP_FEATURES,
@ -75,9 +79,7 @@ const environment = {
QUERY_THREAD_TIMEOUT: QUERY_THREAD_TIMEOUT,
AUTOMATION_THREAD_TIMEOUT:
parseIntSafe(process.env.AUTOMATION_THREAD_TIMEOUT) ||
DEFAULTS.AUTOMATION_THREAD_TIMEOUT > QUERY_THREAD_TIMEOUT
? DEFAULTS.AUTOMATION_THREAD_TIMEOUT
: QUERY_THREAD_TIMEOUT,
DEFAULT_AUTOMATION_TIMEOUT,
BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL,
BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD,
PLUGINS_DIR: process.env.PLUGINS_DIR || DEFAULTS.PLUGINS_DIR,