Skip to content
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

Merged
merged 1 commit into from
Dec 20, 2017
Merged

Added an autostart flag to defer loading #38

merged 1 commit into from
Dec 20, 2017

Conversation

mcollina
Copy link
Member

@mcollina mcollina commented Dec 8, 2017

This should solve fastify/fastify#491

cc @jsumners

@mcollina mcollina requested a review from delvedor December 8, 2017 23:19
@jsumners
Copy link
Member

jsumners commented Dec 9, 2017

Excellent.

Copy link
Member

@delvedor delvedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@coreyfarrell coreyfarrell left a 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
Copy link
Contributor

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.

Copy link
Contributor

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) {...}.

Copy link
Member Author

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.

Copy link
Contributor

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 () {
Copy link
Contributor

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?

Copy link
Member Author

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).

Copy link
Contributor

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.

@mcollina mcollina merged commit a838e70 into master Dec 20, 2017
@mcollina mcollina deleted the autostart branch December 20, 2017 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants