From a4a472b2d8c5da40276c5052af1aee34f630fdc8 Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 4 Jul 2024 12:13:58 +0100 Subject: [PATCH 1/3] Squash the oldRow variable to avoid issues when serialising. Added a try/catch when queuing automations in dev --- .../server/src/api/controllers/row/external.ts | 18 +++++++++++++----- packages/server/src/automations/triggers.ts | 6 +++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/server/src/api/controllers/row/external.ts b/packages/server/src/api/controllers/row/external.ts index 126b11d0c1..601f47b511 100644 --- a/packages/server/src/api/controllers/row/external.ts +++ b/packages/server/src/api/controllers/row/external.ts @@ -72,15 +72,23 @@ export async function patch(ctx: UserCtx) { const row = await sdk.rows.external.getRow(tableId, updatedId, { relationships: true, }) - const enrichedRow = await outputProcessing(table, row, { - squash: true, - preserveLinks: true, - }) + + const [enrichedRow, oldRow] = await Promise.all([ + outputProcessing(table, row, { + squash: true, + preserveLinks: true, + }), + outputProcessing(table, beforeRow, { + squash: true, + preserveLinks: true, + }), + ]) + return { ...response, row: enrichedRow, table, - oldRow: beforeRow, + oldRow, } } diff --git a/packages/server/src/automations/triggers.ts b/packages/server/src/automations/triggers.ts index 399e1a5dd6..12119d36a8 100644 --- a/packages/server/src/automations/triggers.ts +++ b/packages/server/src/automations/triggers.ts @@ -66,7 +66,11 @@ async function queueRelevantRowAutomations( automationTrigger?.inputs && automationTrigger.inputs.tableId === event.row.tableId ) { - await automationQueue.add({ automation, event }, JOB_OPTS) + try { + await automationQueue.add({ automation, event }, JOB_OPTS) + } catch (e) { + console.error("Failed to queue automation", e) + } } } }) From 3a1a600b913b14b860c5513de61eaf56c25bd9c7 Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 4 Jul 2024 15:19:56 +0100 Subject: [PATCH 2/3] PR feedback --- packages/server/src/automations/triggers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/server/src/automations/triggers.ts b/packages/server/src/automations/triggers.ts index 12119d36a8..9c7a3b72c3 100644 --- a/packages/server/src/automations/triggers.ts +++ b/packages/server/src/automations/triggers.ts @@ -2,6 +2,7 @@ import emitter from "../events/index" import { getAutomationParams, isDevAppID } from "../db/utils" import { coerce } from "../utilities/rowProcessor" import { definitions } from "./triggerInfo" +import { logging } from "@budibase/backend-core" // need this to call directly, so we can get a response import { automationQueue } from "./bullboard" import { checkTestFlag } from "../utilities/redis" @@ -69,7 +70,7 @@ async function queueRelevantRowAutomations( try { await automationQueue.add({ automation, event }, JOB_OPTS) } catch (e) { - console.error("Failed to queue automation", e) + logging.logAlert("Failed to queue automation", e) } } } From 87b53ca4523254b2aae809a3559f92e3f1feefa2 Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 4 Jul 2024 15:26:15 +0100 Subject: [PATCH 3/3] Removed dupe import --- packages/server/src/automations/triggers.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/server/src/automations/triggers.ts b/packages/server/src/automations/triggers.ts index 9c7a3b72c3..868c0559e1 100644 --- a/packages/server/src/automations/triggers.ts +++ b/packages/server/src/automations/triggers.ts @@ -2,13 +2,12 @@ import emitter from "../events/index" import { getAutomationParams, isDevAppID } from "../db/utils" import { coerce } from "../utilities/rowProcessor" import { definitions } from "./triggerInfo" -import { logging } from "@budibase/backend-core" // need this to call directly, so we can get a response import { automationQueue } from "./bullboard" import { checkTestFlag } from "../utilities/redis" import * as utils from "./utils" import env from "../environment" -import { context, db as dbCore } from "@budibase/backend-core" +import { context, logging, db as dbCore } from "@budibase/backend-core" import { Automation, Row,