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

fix ready order execution #2333

Merged
merged 3 commits into from Jun 19, 2020
Merged

fix ready order execution #2333

merged 3 commits into from Jun 19, 2020

Conversation

Eomm
Copy link
Member

@Eomm Eomm commented Jun 14, 2020

This test was failing in v3: the order was reverted

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

@Eomm Eomm added bugfix Issue or PR that should land as semver patch v3.x Issue or pr related to Fastify v3 labels Jun 14, 2020
lib/hooks.js Outdated
Comment on lines 103 to 104
exit(err)
done(err)
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand. This looks like two separate callbacks being invoked. How is this deterministic?

Copy link
Member Author

Choose a reason for hiding this comment

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

Here we are appending a function to avvio's ready function.
This is needed to catch the timeout exception and bubble the error up to the user.

The done, is the avvio callback and it must be called to continue the loading of the application

The exit function, instead it is the a local function that will append the onready hooks of all the children in the fastify instance tree and, when the is an error it will stop appending the hooks and returns to the user the error
So this function will be executed every time as the last function for every fastify context.

This has been done to provide to the fastify onready hook a signature without the error handling in charge of the user

Maybe a comment could be helpful?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe a comment could be helpful?

I think so.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @jsumners :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@mcollina mcollina 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
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

lib/hooks.js Outdated Show resolved Hide resolved
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

@mcollina mcollina merged commit 23b48dd into fastify:master Jun 19, 2020
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bugfix Issue or PR that should land as semver patch v3.x Issue or pr related to Fastify v3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants