From 00f55f37b53f5231a7624bfbf7545a2827e5cf90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Fri, 28 Apr 2023 17:01:16 +0200 Subject: [PATCH] allow cancelling execution with wait nodes (with timeout less than 65 seconds) --- packages/nodes-base/nodes/Wait/Wait.node.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/nodes/Wait/Wait.node.ts b/packages/nodes-base/nodes/Wait/Wait.node.ts index a6eff82ad7133a..3b213ad7b7e209 100644 --- a/packages/nodes-base/nodes/Wait/Wait.node.ts +++ b/packages/nodes-base/nodes/Wait/Wait.node.ts @@ -857,10 +857,12 @@ export class Wait implements INodeType { if (waitValue < 65000) { // If wait time is shorter than 65 seconds leave execution active because // we just check the database every 60 seconds. - return new Promise((resolve, _reject) => { - setTimeout(() => { - resolve([this.getInputData()]); - }, waitValue); + return new Promise((resolve, reject) => { + const timer = setTimeout(() => resolve([this.getInputData()]), waitValue); + this.onExecutionCancellation(() => { + clearTimeout(timer); + reject(new Error('Execution cancelled')); + }); }); }