Changing the logic of how automation thread timeout gets applied, so that it can be used properly.

This commit is contained in:
mike12345567 2024-05-13 12:53:44 +01:00
parent fc4f271e4b
commit 92348fb526
3 changed files with 18 additions and 10 deletions

View File

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

View File

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

View File

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