Skip to content

Commit

Permalink
fix: Fix workflow deactivating bug
Browse files Browse the repository at this point in the history
Fix a bug which crashed n8n under some circumstances on shutdown or
workflow deactivate and so resulted in other workflows not getting
deactviated correctly.
  • Loading branch information
janober committed Mar 12, 2022
1 parent bb3fa05 commit 195f104
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions packages/core/src/ActiveWorkflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,33 @@ 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,
},
);
}
}
}
}

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,
},
);
}
}
}
}
Expand Down

0 comments on commit 195f104

Please sign in to comment.