Git Product home page Git Product logo

Comments (5)

mcollina avatar mcollina commented on June 14, 2024 1

The health check in my case is only executed after the provided healthCheckInterval, before that moment the health check isn't executed and thus unhealthy.

Please read the code, you can see it is executed at the right time.

from under-pressure.

mcollina avatar mcollina commented on June 14, 2024

By the look at the code, an externals health check is done during startup. So the scenario you are describing should not be possible.. or in other terms you are routing requests to Fastify before it has completed its bootstrap.

Can you please add a reproduction of this problem?

from under-pressure.

melroy89 avatar melroy89 commented on June 14, 2024

That is indeed strange. The health check in my case is only executed after the provided healthCheckInterval, before that moment the health check isn't executed and thus unhealthy.

See also your documention which confirms that:

"every X milliseconds, the time can be configured with the healthCheckInterval option.
every time the status route is called, if exposeStatusRoute is set to true."

And:

"By default when this function is supplied your service health is considered unhealthy, until it has started to return true."

But sure. I will try to create a git repo for reproduction if you want. Maybe the health handler is added during bootstrap but not executed right away.

from under-pressure.

melroy89 avatar melroy89 commented on June 14, 2024

Sorry Matteo, you are right of course... 👍🏽

The root cause was actually executing MySQL query (SELECT 1 ) in the health check function. This call failed (giving unhealthy), because the MySQL pool connection wasn't present during bootstrap. Moving the @fastify/mysql plugin registration above the under-pressure plugin registration solved that, since then the fastify.mysql.pool is present directly within the under-pressure health check.

However, once I fixed that, I got some other weird synchronization issues with Node, I added await on all the register calls I do now (even on autoload).

That popped-up another error "Fastify instance is already listening" for some reason. I moved fastify.setErrorHandler before registration the all the Fastify plugins. Even if I added await in front of fastify.setErrorHandler (and all register calls are also using await). But that didn't work.

Does setErrorHandler not return a promise just like fastify.register does? So setErrorHandler is unable to make it async (blocking).

Anyhow, I solved it now by executing the plugins in the right order with await, and then I fixed the "Fastify instance is already listening" issue by first register the setErrorHandler before my plugin registrations. 😅

from under-pressure.

melroy89 avatar melroy89 commented on June 14, 2024

Yea I think I'm correct setErrorHandler() is returning a Fastify instance object, not a promise like register() does. Hence I was seeing "Fastify instance is already listening", because I can't make setErrorHandler use await.

from under-pressure.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.