Skip to content

Commit

Permalink
Merge pull request #13670 from Budibase/fix/13660
Browse files Browse the repository at this point in the history
Fixing `AUTOMATION_THREAD_TIMEOUT` environment variable
  • Loading branch information
mike12345567 committed May 13, 2024
2 parents 06b08e5 + ce7fe13 commit dd5a4bd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
14 changes: 10 additions & 4 deletions packages/builder/src/stores/builder/automations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions packages/server/src/api/controllers/automation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
)
Expand Down
10 changes: 6 additions & 4 deletions packages/server/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit dd5a4bd

Please sign in to comment.