From d335ffee7f500ee0f0b62a729653659d4f359549 Mon Sep 17 00:00:00 2001 From: Junyi Date: Wed, 25 Sep 2024 18:25:57 +0800 Subject: [PATCH] fix(plugin-workflow): track error when instruction not exist (#5319) --- .../@nocobase/plugin-workflow/src/server/Processor.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/plugins/@nocobase/plugin-workflow/src/server/Processor.ts b/packages/plugins/@nocobase/plugin-workflow/src/server/Processor.ts index c8e77a6a6e..420f7e0868 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/server/Processor.ts +++ b/packages/plugins/@nocobase/plugin-workflow/src/server/Processor.ts @@ -206,6 +206,9 @@ export default class Processor { public async run(node, input?) { const { instructions } = this.options.plugin; const instruction = instructions.get(node.type); + if (!instruction) { + return Promise.reject(new Error(`instruction [${node.type}] not found for node (#${node.id})`)); + } if (typeof instruction.run !== 'function') { return Promise.reject(new Error('`run` should be implemented for customized execution of the node')); } @@ -232,6 +235,9 @@ export default class Processor { private async recall(node, job) { const { instructions } = this.options.plugin; const instruction = instructions.get(node.type); + if (!instruction) { + return Promise.reject(new Error(`instruction [${node.type}] not found for node (#${node.id})`)); + } if (typeof instruction.resume !== 'function') { return Promise.reject( new Error(`"resume" method should be implemented for [${node.type}] instruction of node (#${node.id})`),