Fastify: AvvioError [Error]: Plugin did not start in time

I’m currently working on a typescript/fastify project (which was a terrible stack choice imo). I’m getting this error while registering routes:

      const err = new AVV_ERR_READY_TIMEOUT(name)
AvvioError [Error]: Plugin did not start in time: 'declareHealthRoutes'. You may have forgotten to call 'done' function or to resolve a Promise
    at Timeout._onTimeout (/home/20015007/Documents/Ecole/EcoWeb/econos-back/node_modules/avvio/plugin.js:122:19)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7) {
  fn: [Function: declareHealthRoutes]

Here is my code:


import { declareArticleRoutes } from "./articlesRoutes";
import { declareContactRoutes } from "./contactRoutes";
import { declareAdminRoutes } from "./adminRoutes";
import { verifyJWT} from "../services/tokenService";
import { declareHealthRoutes } from "./healthRoutes";
function declareRoutes(fastify: FastifyInstance) {


import {FastifyInstance, FastifyReply, FastifyRequest} from "fastify";

const healthSchema = {
    response: {
        200: {}

function declareHealthRoutes(fastify: FastifyInstance): FastifyInstance {

        method: 'GET',
        url: '/health2',
        schema: healthSchema,
        handler: (req: FastifyRequest, reply: FastifyReply) => {
            return reply.status(200).send({});
    return fastify

export { declareHealthRoutes };

All of my routes are declared this simple way.

Just to say: I know how to get this code working (declareHealthRoutes(fastify) does register my route) but i’d like to understand why this is not working and if i’m not using the register the wrong way.

Any help is appreciated !

>Solution :

The function declareHealthRoutes must be async or call the callback:

async function declareHealthRoutes(fastify) { }

// or
function declareHealthRoutes(fastify, opts, next) {

otherwise, fastify does not know what the plugin is doing.

Leave a Reply