fix: Fix workflow deactivating bug

Fix a bug which crashed n8n under some circumstances on shutdown or
workflow deactivate and so resulted in other workflows not getting
deactviated correctly.
This commit is contained in:
Jan Oberhauser 2022-03-12 19:50:42 +01:00
parent bb3fa05318
commit 195f104ef5

View file

@ -255,7 +255,16 @@ export class ActiveWorkflows {
if (workflowData.triggerResponses) {
for (const triggerResponse of workflowData.triggerResponses) {
if (triggerResponse.closeFunction) {
await triggerResponse.closeFunction();
try {
await triggerResponse.closeFunction();
} catch (error) {
Logger.error(
`There was a problem deactivating trigger of workflow "${id}": "${error.message}"`,
{
workflowId: id,
},
);
}
}
}
}
@ -263,7 +272,16 @@ export class ActiveWorkflows {
if (workflowData.pollResponses) {
for (const pollResponse of workflowData.pollResponses) {
if (pollResponse.closeFunction) {
await pollResponse.closeFunction();
try {
await pollResponse.closeFunction();
} catch (error) {
Logger.error(
`There was a problem deactivating polling trigger of workflow "${id}": "${error.message}"`,
{
workflowId: id,
},
);
}
}
}
}