Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Replace throw with warning when deactivating a non-active workflow #6969

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/cli/src/ActiveWorkflowRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,10 @@ export class ActiveWorkflowRunner implements IWebhookManager {
// if it's active in memory then it's a trigger
// so remove from list of actives workflows
if (this.activeWorkflows.isActive(workflowId)) {
await this.activeWorkflows.remove(workflowId);
Logger.verbose(`Successfully deactivated workflow "${workflowId}"`, { workflowId });
const removalSuccess = await this.activeWorkflows.remove(workflowId);
if (removalSuccess) {
Logger.verbose(`Successfully deactivated workflow "${workflowId}"`, { workflowId });
}
}
}
}
7 changes: 5 additions & 2 deletions packages/core/src/ActiveWorkflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,13 @@ export class ActiveWorkflows {
*
* @param {string} id The id of the workflow to deactivate
*/
async remove(id: string): Promise<void> {
async remove(id: string): Promise<boolean> {
if (!this.isActive(id)) {
// Workflow is currently not registered
throw new Error(
Logger.warn(
`The workflow with the id "${id}" is currently not active and can so not be removed`,
);
return false;
}

const workflowData = this.workflowData[id];
Expand Down Expand Up @@ -244,5 +245,7 @@ export class ActiveWorkflows {
}

delete this.workflowData[id];

return true;
}
}