Addressing PR comments.

This commit is contained in:
mike12345567 2024-02-14 17:15:42 +00:00
parent fa585fe69d
commit ea5d04e1d3
6 changed files with 12 additions and 15 deletions

View File

@ -10,7 +10,7 @@ import {
removeDeprecated,
} from "../../automations/utils"
import { deleteEntityMetadata } from "../../utilities"
import { MetadataTypes, AUTOMATION_SYNC_TIMEOUT } from "../../constants"
import { MetadataTypes } from "../../constants"
import { setTestFlag, clearTestFlag } from "../../utilities/redis"
import { context, cache, events, db as dbCore } from "@budibase/backend-core"
import { automations, features } from "@budibase/pro"
@ -24,6 +24,7 @@ import {
import { getActionDefinitions as actionDefs } from "../../automations/actions"
import sdk from "../../sdk"
import { builderSocket } from "../../websockets"
import env from "../../environment"
async function getActionDefinitions() {
return removeDeprecated(await actionDefs())
@ -274,7 +275,9 @@ export async function trigger(ctx: UserCtx) {
automation,
{
fields: ctx.request.body.fields,
timeout: ctx.request.body.timeout * 1000 || AUTOMATION_SYNC_TIMEOUT,
timeout:
ctx.request.body.timeout * 1000 ||
env.getDefaults().AUTOMATION_SYNC_TIMEOUT,
},
{ getResponses: true }
)

View File

@ -11,7 +11,7 @@ import {
import * as triggers from "../triggers"
import { context } from "@budibase/backend-core"
import { features } from "@budibase/pro"
import { AUTOMATION_SYNC_TIMEOUT } from "../../constants"
import env from "../../environment"
export const definition: AutomationStepSchema = {
name: "Trigger an automation",
@ -77,7 +77,8 @@ export async function run({ inputs }: AutomationStepInput) {
automation,
{
fields: { ...fieldParams },
timeout: inputs.timeout * 1000 || AUTOMATION_SYNC_TIMEOUT,
timeout:
inputs.timeout * 1000 || env.getDefaults().AUTOMATION_SYNC_TIMEOUT,
},
{ getResponses: true }
)

View File

@ -3,7 +3,7 @@ jest.spyOn(global.console, "error")
import * as setup from "./utilities"
import * as automation from "../index"
import { serverLogAutomation } from "../../tests/utilities/structures"
import { AUTOMATION_ASYNC_TIMEOUT } from "../../constants"
import env from "../../environment"
describe("Test triggering an automation from another automation", () => {
let config = setup.getConfig()
@ -25,7 +25,7 @@ describe("Test triggering an automation from another automation", () => {
const inputs: any = {
automation: {
automationId: newAutomation._id,
timeout: AUTOMATION_ASYNC_TIMEOUT,
timeout: env.getDefaults().AUTOMATION_THREAD_TIMEOUT,
},
}
const res = await setup.runStep(
@ -40,7 +40,7 @@ describe("Test triggering an automation from another automation", () => {
const inputs: any = {
automation: {
automationId: null,
timeout: AUTOMATION_ASYNC_TIMEOUT,
timeout: env.getDefaults().AUTOMATION_THREAD_TIMEOUT,
},
}
const res = await setup.runStep(

View File

@ -1,6 +0,0 @@
import { Duration } from "@budibase/backend-core"
import env from "../environment"
const defaults = env.getDefaults()
export const AUTOMATION_SYNC_TIMEOUT = Duration.fromMinutes(2).toMs()
export const AUTOMATION_ASYNC_TIMEOUT = defaults.QUERY_THREAD_TIMEOUT

View File

@ -6,8 +6,6 @@ import {
TableSourceType,
} from "@budibase/types"
export * from "./automations"
export enum FilterTypes {
STRING = "string",
FUZZY = "fuzzy",

View File

@ -21,6 +21,7 @@ function parseIntSafe(number?: string) {
const DEFAULTS = {
QUERY_THREAD_TIMEOUT: 10000,
AUTOMATION_THREAD_TIMEOUT: 12000,
AUTOMATION_SYNC_TIMEOUT: 120000,
AUTOMATION_MAX_ITERATIONS: 200,
JS_PER_EXECUTION_TIME_LIMIT_MS: 1000,
TEMPLATE_REPOSITORY: "app",