-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
refactor(core): Move ExecutionLifecycleHooks to core #13042
Conversation
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
packages/core/src/execution-engine/execution-lifecycle-hooks.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com>
@@ -61,7 +61,7 @@ export class WorkflowRunner { | |||
startedAt: Date, | |||
executionMode: WorkflowExecuteMode, | |||
executionId: string, | |||
hooks?: WorkflowHooks, | |||
hooks?: ExecutionLifecycleHooks, |
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.
Every call to processError
passes hooks
, can we make them required and remove the optional access below?
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'll try to make hooks required wherever I can, but we'll still have some places where it'll be optional, until we rewrite credentials testing to stop using the execution engine.
packages/core/src/execution-engine/__tests__/workflow-execute.test.ts
Outdated
Show resolved
Hide resolved
packages/core/src/execution-engine/execution-lifecycle-hooks.ts
Outdated
Show resolved
Hide resolved
packages/core/src/execution-engine/execution-lifecycle-hooks.ts
Outdated
Show resolved
Hide resolved
packages/core/src/execution-engine/__tests__/execution-lifecycle-hooks.test.ts
Outdated
Show resolved
Hide resolved
packages/core/src/execution-engine/__tests__/execution-lifecycle-hooks.test.ts
Outdated
Show resolved
Hide resolved
await expect(hooks.runHook('nodeExecuteBefore', ['testNode'])).rejects.toThrow('Hook failed'); | ||
}); | ||
}); | ||
}); |
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.
More ideas :)
- if a handler fails, should continue executing remaining handlers
- if a hook has no handlers, running the hook should not throw
- if two handlers are added for a hook, both should be called (not overridden)
mock<{ | ||
[K in keyof ExecutionLifecyleHookHandlers]: ExecutionLifecyleHookHandlers[K][number]; | ||
}>(); |
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.
Or mock<ExecutionLifecyleHookHandlers>()
?
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.
couldn't get this to work
const typedHookFunction = hookFunction as unknown as ( | ||
this: ExecutionLifecycleHooks, | ||
...args: Params | ||
) => Promise<void>; | ||
await typedHookFunction.apply(this, parameters); | ||
} |
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.
Spent 15m but no luck :/
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.
this file needs another round of cleanup. same with the TODO
on line 90
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.
🚀
n8n
|
Project |
n8n
|
Branch Review |
master
|
Run status |
|
Run duration | 04m 37s |
Commit |
|
Committer | कारतोफ्फेलस्क्रिप्ट™ |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
0
|
|
5
|
|
0
|
|
434
|
View all changes introduced in this branch ↗︎ |
✅ All Cypress E2E specs passed |
|
✅ All Cypress E2E specs passed |
Summary
This is a continuation of the execution-lifecycle hooks refactor. extracted out of #12364.
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)