Comments (5)
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.
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.
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.
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.
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)
- Histogram returning NaN HOT 7
- Allow passthrough of `exposeHeadRoute` route param HOT 2
- Setting logLevel option for status route has no effect HOT 6
- How to find out in a custom healthCheck whether the service is under pressure? HOT 3
- consider setTimeout instead of setInterval for polling HOT 13
- Make new release HOT 5
- Ambiguous supported versions documentation HOT 2
- bug when setting custom error handler
- Exclude paths/routes from 503 errors HOT 6
- Achieve 100% test coverage
- An in-range update of @types/node is breaking the build 🚨 HOT 12
- Additional route options are not passed when exposing status route HOT 1
- Your .dependabot/config.yml contained invalid details HOT 1
- Use custom Error instance HOT 4
- How to hide it's default route created by exposeStatusRoute:'/live' in swagger ui. HOT 1
- Breaking fastify server! HOT 1
- use eventLoopUtilization if it is available HOT 9
- Custom function for process metrics HOT 6
- Allow custom response from healthCheck function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from under-pressure.