-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
refactor(core): Refactor nodes loading (no-changelog) #7283
Conversation
Great PR! Please pay attention to the following items before merging: Files matching
Files matching
Make sure to check off this list before asking for review. |
c2c2c70
to
ac5216c
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.
Tested manually, still working, only minor comments.
@@ -571,9 +570,11 @@ export class Server extends AbstractServer { | |||
} | |||
|
|||
if (config.getEnv('nodes.communityPackages.enabled')) { | |||
controllers.push( | |||
new NodesController(config, this.loadNodesAndCredentials, this.push, internalHooks), | |||
// eslint-disable-next-line @typescript-eslint/naming-convention |
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.
Now or later, maybe it's time to relax or remove this rule. Every dynamically loaded class will trigger it.
ac5216c
to
49ab975
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #7283 +/- ##
==========================================
- Coverage 33.46% 33.41% -0.05%
==========================================
Files 3389 3389
Lines 206599 206610 +11
Branches 22288 22284 -4
==========================================
- Hits 69143 69049 -94
- Misses 136337 136444 +107
+ Partials 1119 1117 -2
☔ View full report in Codecov by Sentry. |
@@ -50,20 +40,20 @@ export class LoadNodesAndCredentials implements INodesAndCredentials { | |||
|
|||
includeNodes = config.getEnv('nodes.include'); | |||
|
|||
credentialTypes: ICredentialTypes; |
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 dependency tree was too messy. by moving code out into CommunityPackagesService
and FrontendService
, this class is a lot more leaner, and there are fewer cyclic dependencies now.
Also, the code that got moved out isn't loaded in webhook
and worker
services anymore.
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials'; | ||
|
||
@Service() | ||
export class FrontendService { |
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.
will move all fronted-settings out of Server.ts
and into this class in a separate PR.
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 can take this over as well if you like.
|
||
LoggerProxy.init(getLogger()); | ||
LoggerProxy.init(mock<ILogger>()); |
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 love this, we should be mocking the logger more often.
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 have a branch to convert Logger into a service, and mock that everywhere. no more LoggerProxy
in the cli
package.
|
||
class CredentialsOverwritesClass { | ||
@Service() | ||
export class CredentialsOverwrites { |
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.
For understanding: What's the difference between the overwrites that happen in CredentialsOverwrites
vs. the overwrites that happen in the FrontendService
? Why do we need both and for them to be separate?
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.
The overwrites in FrontendService
are only used in the frontend, and that code should not run on worker or webhooks. That said, we could still move that code into a method on CredentialsOverwrites
, if that looks cleaner.
let me know.
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.
Skimming through them they look very similar and with no context or method documentation I do not find the difference clear. Running low on time so I'll leave this be for now.
|
||
await writeStaticJSON('nodes', this.types.nodes); | ||
await writeStaticJSON('credentials', this.types.credentials); | ||
addPostProcessor(fn: () => Promise<void>) { |
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 take it we went for this to avoid adding more dependencies.
There are only two post-processors for now, but over time I worry it can become rather hard to keep track of what's getting added and later called when and in what order.
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.
yeah. I couldn't come up with a better way to decouple this processing pipeline. This works for now, but I'm very much open to suggestions.
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 keep thinking if there's another way but let's not block on this.
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 come back to test manually: community nodes, hot reload, overwrites, etc.
Edit: Tested, all fine
return filePath; | ||
} | ||
} | ||
return undefined; |
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.
return undefined; |
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.
removing this makes eslint complain about
Not all code paths return a value
this.frontendService.generateTypes(), | ||
); | ||
await this.frontendService.generateTypes(); |
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.
So we have to both register and call generateTypes
because LoadNodesAndCredentials.init()
was already called during startup at BaseCommand
but without this postprocessor? So we registering this postprocessor only for cases where we reload as in with community packages or hot reload?
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.
unfortunately yes. but that also makes sense as LoadNodesAndCredentials.init
is called in webhook and worker services as well. It would have been cool to be able to defer postProcessLoaders
somehow, but everything I tried so far made this code even more twisted.
I'd definitely like to simplify this, but I'm out of ideas for now.
packagesMissing: { | ||
// Used to have a persistent list of packages | ||
doc: 'Contains a comma separated list of packages that failed to load during startup', | ||
format: String, | ||
default: '', | ||
}, |
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.
@krynble Is this fine to remove? Or was there a reason this needed to be an env in the first place?
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.
there was never an env variable for this. and this should never have been a config variable either. looking at the code where this was originally added, it looks like we needed a central place to store this string while the application was running, because the code using this flag was scattered across multiple files.
now, this info is centralized in the CommunityPackagesService
.
Passing run #2436 ↗︎
Details:
Review all test suite changes for PR #7283 ↗︎ |
✅ All Cypress E2E specs passed |
* master: (42 commits) fix(editor): Make workflow history button available only for dev builds (#7392) refactor: Upgrade to pnpm 8.9 (no-changelog) (#7393) ci: Identify NPM releases as `stable` (no-changelog) fix(editor): Implement canvas zoom UX improvements (#7376) feat(core): Switch binary filesystem mode to nested path structure (#7307) fix(editor): Fix completions for `.json` on quoted node name in Code node (#7382) fix(Notion Node): Handle empty values correctly for Notion selects + multi selects (#7383) feat(editor): Make PDF and Audio binary-data viewable in the UI (#7367) fix(Google Sheets Node): Fix "Maximum call stack size exceeded" error on too many rows (#7384) refactor(core): Refactor nodes loading (no-changelog) (#7283) fix(core): Add an option to enable postgres ssl with default certs (#6889) feat(editor): Workflow history [WIP]- Add restore and clone into new workflow actions (no-changelog) (#7359) fix(HTML Node): Update property fields to not use expressions on drag (#7379) fix: Add role check for upgrade path (#7374) fix(editor): Remove excess margin below run data editor (#7372) fix(Google Drive Trigger Node): Add Shared Drives support (#7369) feat(core): Add Job Summary to Worker response (#7360) feat(Execute Workflow Node): Run once for each item mode (#7289) refactor(core): Move `copyInputItems` to node helpers (no-changelog) (#7299) refactor(core): Create controller for binary data (no-changelog) (#7363) ... # Conflicts: # cypress/e2e/5-ndv.cy.ts
Got released with |
This also fixes PAY-605