From 28cdb16e085831d7c2e7c3e0594a9e9d45d2d0e1 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Sat, 20 Aug 2022 11:02:22 +0100 Subject: [PATCH 1/2] enable stalled job disabling --- packages/server/src/automations/listeners.ts | 4 ++-- packages/server/src/threads/automation.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/server/src/automations/listeners.ts b/packages/server/src/automations/listeners.ts index d53d0dddee..9f8667bd29 100644 --- a/packages/server/src/automations/listeners.ts +++ b/packages/server/src/automations/listeners.ts @@ -4,11 +4,11 @@ import * as automation from "../threads/automation" export const addListeners = (queue: Queue) => { logging(queue) - // handleStalled(queue) + handleStalled(queue) } const handleStalled = (queue: Queue) => { - queue.on("active", async (job: Job) => { + queue.on("stalled", async (job: Job) => { await automation.removeStalled(job as AutomationEvent) }) } diff --git a/packages/server/src/threads/automation.ts b/packages/server/src/threads/automation.ts index 04b6ae413c..3136155869 100644 --- a/packages/server/src/threads/automation.ts +++ b/packages/server/src/threads/automation.ts @@ -473,9 +473,9 @@ export function execute(input: AutomationEvent, callback: WorkerCallback) { }) } -export const removeStalled = (input: AutomationEvent) => { +export const removeStalled = async (input: AutomationEvent) => { const appId = input.data.event.appId - doInAppContext(appId, async () => { + await doInAppContext(appId, async () => { const automationOrchestrator = new Orchestrator( input.data.automation, input.data.event, From 917bb96ae651e481c054a287099333c6785011a4 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Sat, 20 Aug 2022 11:42:51 +0100 Subject: [PATCH 2/2] add on() to mock queue --- packages/server/src/utilities/queue/inMemoryQueue.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/server/src/utilities/queue/inMemoryQueue.js b/packages/server/src/utilities/queue/inMemoryQueue.js index 620b65cf38..79781f9283 100644 --- a/packages/server/src/utilities/queue/inMemoryQueue.js +++ b/packages/server/src/utilities/queue/inMemoryQueue.js @@ -113,6 +113,10 @@ class InMemoryQueue { async getJob() { return {} } + + on() { + // do nothing + } } module.exports = InMemoryQueue