Register fastify
plugin with a timeout
NB: this plugin is going to DEPRECATED because it suggests a bad approach.
npm i --save fastify-register-timeout
Registering this plugin
fastify.register(require('fastify-register-timeout'), {
timeout: 5000 // ms
})
to use like this
fastfiy.registerWithTimeout(require('some-async-plugin'))
NB: in case of timeout, an exception is thrown with the function name as message. This is mean that the anonymous function should not be used here!
There're two reason for this plugin:
- in some case you need to know if your external dependencies are reachable before starting your server.
- during the test, you need to know which plugin fails