diff --git a/packages/backend-core/src/utils/utils.ts b/packages/backend-core/src/utils/utils.ts index 30cf55b149..046f8aaf94 100644 --- a/packages/backend-core/src/utils/utils.ts +++ b/packages/backend-core/src/utils/utils.ts @@ -226,8 +226,19 @@ export function isClient(ctx: Ctx) { return ctx.headers[Header.TYPE] === "client" } -export function timeout(timeMs: number) { - return new Promise(resolve => setTimeout(resolve, timeMs)) +export function timeout( + timeMs: number, + opts?: { reject?: boolean } +): Promise { + return new Promise((resolve, reject) => { + setTimeout(() => { + if (opts?.reject) { + reject(new Error(`timed out - ${timeMs}ms`)) + } else { + resolve() + } + }, timeMs) + }) } export function isAudited(event: Event) { diff --git a/packages/builder/src/components/integration/RestQueryViewer.svelte b/packages/builder/src/components/integration/RestQueryViewer.svelte index d6a8fe6fc3..74aaa5386f 100644 --- a/packages/builder/src/components/integration/RestQueryViewer.svelte +++ b/packages/builder/src/components/integration/RestQueryViewer.svelte @@ -159,7 +159,7 @@ newQuery.fields.queryString = queryString newQuery.fields.authConfigId = authConfigId newQuery.fields.disabledHeaders = restUtils.flipHeaderState(enabledHeaders) - newQuery.schema = schema + newQuery.schema = schema || {} return newQuery } diff --git a/packages/server/src/automations/bullboard.ts b/packages/server/src/automations/bullboard.ts index df784eacff..34f18754a2 100644 --- a/packages/server/src/automations/bullboard.ts +++ b/packages/server/src/automations/bullboard.ts @@ -15,7 +15,7 @@ const PATH_PREFIX = "/bulladmin" export async function init() { // Set up queues for bull board admin - const backupQueue = await backups.getBackupQueue() + const backupQueue = backups.getBackupQueue() const queues = [automationQueue] if (backupQueue) { queues.push(backupQueue) diff --git a/packages/server/src/automations/steps/executeQuery.ts b/packages/server/src/automations/steps/executeQuery.ts index a9517b01a0..d3dc6a219c 100644 --- a/packages/server/src/automations/steps/executeQuery.ts +++ b/packages/server/src/automations/steps/executeQuery.ts @@ -10,6 +10,8 @@ import { AutomationStepSchema, AutomationStepType, } from "@budibase/types" +import { utils } from "@budibase/backend-core" +import env from "../../environment" export const definition: AutomationStepSchema = { name: "External Data Connector", @@ -84,7 +86,10 @@ export async function run({ inputs, appId, emitter }: AutomationStepInput) { }) try { - await queryController.executeV2(ctx, { isAutomation: true }) + await Promise.race([ + queryController.executeV2(ctx, { isAutomation: true }), + utils.timeout(env.QUERY_THREAD_TIMEOUT, { reject: true }), + ]) const { data, ...rest } = ctx.body return {