-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: onReady plugin hook #210
Conversation
🦋 Changeset detectedLatest commit: e82e9b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I'm not sure about this. I added a new In principle, I could have used |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #210 +/- ##
==========================================
+ Coverage 94.09% 94.10% +0.01%
==========================================
Files 59 59
Lines 2862 2868 +6
Branches 338 340 +2
==========================================
+ Hits 2693 2699 +6
Misses 167 167
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
616f0f8
to
d929eb7
Compare
@@ -148,6 +150,10 @@ export default class Impl implements Kopflos { | |||
this.start = onetime(async function (this: Impl) { | |||
await Promise.all(this.plugins.map(plugin => plugin.onStart?.())) | |||
}).bind(this) | |||
|
|||
this.ready = onetime(async function (this: Impl) { | |||
await Promise.all(this.plugins.map(plugin => plugin.onReady?.())) |
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.
do we need to await
the promises here? is the server really ready to serve requests until the plugins finish their onReady
task?
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.
True, technically, this await
is irrelevant here because it's not awaited when the CLI starts:
kopflos/packages/cli/lib/command/serve.ts
Lines 50 to 53 in e82e9b5
const server = app.listen(port, host, () => { | |
log.info(`Server running on ${port}. API URL: ${config.baseIri}`) | |
instance.ready() | |
}) |
And yes, the server should be able to serve requests. Of course some may still depend on the code in onReady
hooks...
No description provided.