-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add post hooks for workflow deletion #9258
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Adds post-query hooks to handle cascading deletion of workflow sub-entities (versions, runs, event listeners) when workflows are deleted, serving as a temporary solution until proper soft deletion cascade is implemented.
- Critical bug:
cleanWorkflowsSubEntities
in/packages/twenty-server/src/modules/workflow/common/workspace-services/workflow-common.workspace-service.ts
uses incorrect entity typeWorkflowVersionWorkspaceEntity
for workflowRun and eventListener repositories - Performance issue:
map()
is used incorrectly for async operations without awaiting results incleanWorkflowsSubEntities
- Missing error handling for delete operations in
cleanWorkflowsSubEntities
- No transaction wrapping for the cascade deletion operations, risking partial deletions
4 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile
...twenty-server/src/modules/workflow/common/query-hooks/workflow-delete-one.post-query.hook.ts
Show resolved
Hide resolved
...twenty-server/src/modules/workflow/common/query-hooks/workflow-delete-one.post-query.hook.ts
Show resolved
Hide resolved
...y-server/src/modules/workflow/common/workspace-services/workflow-common.workspace-service.ts
Outdated
Show resolved
Hide resolved
...y-server/src/modules/workflow/common/workspace-services/workflow-common.workspace-service.ts
Outdated
Show resolved
Hide resolved
...y-server/src/modules/workflow/common/workspace-services/workflow-common.workspace-service.ts
Outdated
Show resolved
Hide resolved
...wenty-server/src/modules/workflow/common/query-hooks/workflow-delete-many.post-query.hook.ts
Show resolved
Hide resolved
packages/twenty-server/src/modules/workflow/common/query-hooks/workflow-query-hook.module.ts
Show resolved
Hide resolved
ed3c40f
to
32c768b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
'workflowEventListener', | ||
); | ||
|
||
workflowIds.map(async (workflowId) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess if you really want to fire-and-forget, you don't need map here but foreach instead. This won't guarantee the execution of your promises though I'd suggest using Promise.all()
Delete all workflow sub objects when workflow is deleted. Other sub objects cannot be deleted otherwise.
We do not listen to deletion events so I am not adding them. Those post hooks should be deleted Q1 once we properly handle cascade for soft deletion