-
Notifications
You must be signed in to change notification settings - Fork 40
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
Added an autostart flag to defer loading #38
Conversation
Excellent. |
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
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.
Request for changes is for the lack of wrap
support. Although I'd like to get rid of the unreachable error block that's not essential.
Plugin.loadPlugin.call(this, main, (err) => { | ||
debug('root plugin ready') | ||
if (err) { | ||
this._error = err |
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.
Unless this._doStart is called with an error argument this is unreachable. I found this while working on a patch to increase test coverage.
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.
Not sure what happened, my code selection got moved up a couple lines. should have selected the lines within if (err) {...}
.
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 is not correct. Here we receive the errors of all the loaded plugins.
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 tried to get an error to reach this block, I was unsuccessful so I analyzed the code. I'm confident that it's unreachable but that's not important to this review.
if (this.booted) { | ||
throw new Error('root plugin has already booted') | ||
} | ||
Boot.prototype.start = function () { |
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.
Should this be added to wrap
?
Also if this.started is already true do we want to run this._doStart again?
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 don’t think we should add it to wrap? Why would you want to do it?
An avvio instance can be booted only once. Otherwise too many edge cases happens (this is discussed elsewhere).
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.
Nevermind I looked at the docs again it explicitly states which functions are exposed. It needs to be updated to list close
and onClose
but that's not related to this review. I'll submit a doc update for that later.
This should solve fastify/fastify#491
cc @jsumners