fastify-swagger-ui icon indicating copy to clipboard operation
fastify-swagger-ui copied to clipboard

Server fails at startup with timeout (AVV_ERR_PLUGIN_EXEC_TIMEOUT)

Open chrisbenincasa opened this issue 1 year ago • 2 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.26.0

Plugin version

4.0.0

Node.js version

20.11.1

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

6.6.16-linuxkit

Description

This was forwarded to me from a user of an app I maintain (original issue): https://github.com/chrisbenincasa/tunarr/issues/550

This happened to the user before when the app used an earlier version of this plugin. I have since bumped the version and this issue has come back. I am unable to reproduce it unfortunately, so I don't have a lot more detail to provide. It does seem like swagger-ui gets into a state where it simply cannot start, because once the user hits the error, they are unable to start the server at all. Any thoughts on what could prevent the done callback from firing? Or is there a way we could enable/add extra logging to see the cause here?

FastifyError [Error]: Plugin did not start in time: '@fastify/swagger-ui'. You may have forgotten to call 'done' function or to resolve a Promise
    at Timeout._onTimeout (file:///tunarr/server/build/bundle.js:181438:35)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  code: 'AVV_ERR_PLUGIN_EXEC_TIMEOUT',
  statusCode: 500,
  fn: <ref *1> [AsyncFunction: fastifySwaggerUi] {
    default: [Circular *1],
    fastifySwaggerUi: [Circular *1],
    [Symbol(skip-override)]: true,
    [Symbol(fastify.display-name)]: '@fastify/swagger-ui',
    [Symbol(plugin-meta)]: {
      fastify: '4.x',
      name: '@fastify/swagger-ui',
      dependencies: [Array]
    }
  }
}

Link to code that reproduces the bug

No response

Expected Behavior

No response

chrisbenincasa avatar Jun 19 '24 11:06 chrisbenincasa

It appears you are doing some bundling. fastify-swagger-ui assumes to be able to read from the file system to load some of the styles/html files. You should be able to tune your bundler to do so.

mcollina avatar Jun 19 '24 19:06 mcollina

The files are included in the file bundle / container. Generally, we've found that the plugin works in the bundle for some time and then somehow can get corrupted. Do you think this could be from a missing file or if the target directory changes somehow?

chrisbenincasa avatar Jun 19 '24 20:06 chrisbenincasa