Giter Club home page Giter Club logo

Comments (9)

Uzlopak avatar Uzlopak commented on May 20, 2024 1

This indicates that the connection to the db could not be established, as the plugin never resolves.

from fastify-mongodb.

mcollina avatar mcollina commented on May 20, 2024

I think we need to pass a custom connectTimeoutMS option set to 5s when we create the MongoClient.

Wdyt?

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

from fastify-mongodb.

eisenhaus335 avatar eisenhaus335 commented on May 20, 2024

I think this is problem of fastify.register that has timeout time when register plugin, if i read the error correctly. It would be best to catch the error than make connectTimeoutMS. I think adding custom connectTimeoutMS option will not catch the error. But not sure, maybe anyone has more idea on this? I also doesnt know how fastify works in general

from fastify-mongodb.

climba03003 avatar climba03003 commented on May 20, 2024

I think this is problem of fastify.register that has timeout time when register plugin, if i read the error correctly. It would be best to catch the error than make connectTimeoutMS. I think adding custom connectTimeoutMS option will not catch the error. But not sure, maybe anyone has more idea on this? I also doesnt know how fastify works in general

Inside the plugin, it already forward the error to fastify.
https://github.com/fastify/fastify-mongodb/blob/master/index.js#L90

As the mongodb default timeout (30s) is longer than fastify plugin timeout (10s), so it cannot forward the error properly.

from fastify-mongodb.

eisenhaus335 avatar eisenhaus335 commented on May 20, 2024

Anyone that would like to make PR request could make it. I tried to make test case and the code and struggling with that. I dont know how to make error case like make making the mongo to timeout

I am still very new in open project like this. The code still a bit advanced for me

from fastify-mongodb.

ihadabs avatar ihadabs commented on May 20, 2024

I'm using fastify-autoload to load my plugins and one of the files contains:

export default fp<FastifyMongodbOptions>(async function(fastify, opts) {
	await fastify.register(require('fastify-mongodb'), {
		// force to close the mongodb connection when app stopped
		// the default value is false
		forceClose: true,
		url: config.mongoUri,
		database: config.mongoDefaultDbName,
	});
});

for some reason its failing to load with the following error:

[App] Error: ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: async function (fastify, opts) { -- await fastify.register(require('fastify-mongodb'), {. You may have forgotten to call 'done' function or to resolve a Promise
[App]     at Timeout._onTimeout (/Users/***/node_modules/avvio/plugin.js:123:19)
[App]     at listOnTimeout (internal/timers.js:554:17)
[App]     at processTimers (internal/timers.js:497:7) {
[App]   code: 'ERR_AVVIO_PLUGIN_TIMEOUT',
[App]   fn: <ref *1> [AsyncFunction (anonymous)] {
[App]     default: [Circular *1],
[App]     [Symbol(skip-override)]: true,
[App]     [Symbol(fastify.display-name)]: 'connector-auto-7',
[App]     [Symbol(plugin-meta)]: { name: 'connector-auto-7' }
[App]   }
[App] }

Giving that it worked before.

from fastify-mongodb.

climba03003 avatar climba03003 commented on May 20, 2024

I'm using fastify-autoload to load my plugins and one of the files contains:

export default fp<FastifyMongodbOptions>(async function(fastify, opts) {
	await fastify.register(require('fastify-mongodb'), {
		// force to close the mongodb connection when app stopped
		// the default value is false
		forceClose: true,
		url: config.mongoUri,
		database: config.mongoDefaultDbName,
	});
});

for some reason its failing to load with the following error:

[App] Error: ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: async function (fastify, opts) { -- await fastify.register(require('fastify-mongodb'), {. You may have forgotten to call 'done' function or to resolve a Promise
[App]     at Timeout._onTimeout (/Users/***/node_modules/avvio/plugin.js:123:19)
[App]     at listOnTimeout (internal/timers.js:554:17)
[App]     at processTimers (internal/timers.js:497:7) {
[App]   code: 'ERR_AVVIO_PLUGIN_TIMEOUT',
[App]   fn: <ref *1> [AsyncFunction (anonymous)] {
[App]     default: [Circular *1],
[App]     [Symbol(skip-override)]: true,
[App]     [Symbol(fastify.display-name)]: 'connector-auto-7',
[App]     [Symbol(plugin-meta)]: { name: 'connector-auto-7' }
[App]   }
[App] }

Giving that it worked before.

@ihadabs If it throw about fastify-mongodb, most of the reason is it cannot connect to the database instance. Please check the database connectivity.

For this issue, I have tested both connectTimeoutMS and socketTimeoutMS, they do not behave what I believe. So, I think it is hard to solve this issue in a short period of time.
cc @eisenhaus335

from fastify-mongodb.

floydjones1 avatar floydjones1 commented on May 20, 2024

I'm using fastify-autoload to load my plugins and one of the files contains:

export default fp<FastifyMongodbOptions>(async function(fastify, opts) {
	await fastify.register(require('fastify-mongodb'), {
		// force to close the mongodb connection when app stopped
		// the default value is false
		forceClose: true,
		url: config.mongoUri,
		database: config.mongoDefaultDbName,
	});
});

for some reason its failing to load with the following error:

[App] Error: ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: async function (fastify, opts) { -- await fastify.register(require('fastify-mongodb'), {. You may have forgotten to call 'done' function or to resolve a Promise
[App]     at Timeout._onTimeout (/Users/***/node_modules/avvio/plugin.js:123:19)
[App]     at listOnTimeout (internal/timers.js:554:17)
[App]     at processTimers (internal/timers.js:497:7) {
[App]   code: 'ERR_AVVIO_PLUGIN_TIMEOUT',
[App]   fn: <ref *1> [AsyncFunction (anonymous)] {
[App]     default: [Circular *1],
[App]     [Symbol(skip-override)]: true,
[App]     [Symbol(fastify.display-name)]: 'connector-auto-7',
[App]     [Symbol(plugin-meta)]: { name: 'connector-auto-7' }
[App]   }
[App] }

Giving that it worked before.

Had the same issue just had to debug more and my mongo docker container wasn't bound properly lol

from fastify-mongodb.

hoanghiep1x0 avatar hoanghiep1x0 commented on May 20, 2024

Why does connect localhost:27017 work but connect to mongo with the address mongodb+srv://user:[email protected]/

then get an error how to fix it

Plugin did not start in time: '@fastify/mongodb'. You may have forgotten to call 'done' function or to resolve a Promise
    at Timeout._onTimeout (/Users/admin/Desktop/app/docker-truyen/service-authencation/node_modules/avvio/plugin.js:122:19)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7) {
  code: 'AVV_ERR_READY_TIMEOUT',
  fn: <ref *1> [AsyncFunction: fastifyMongodb] {
    default: [Circular *1],
    fastifyMongodb: [Circular *1],
    ObjectId: [Function: ObjectId] {
      getInc: [Function (anonymous)],
      generate: [Function (anonymous)],
      createPk: [Function (anonymous)],
      createFromTime: [Function (anonymous)],
      createFromHexString: [Function (anonymous)],
      isValid: [Function (anonymous)],
      fromExtendedJSON: [Function (anonymous)],
      index: 16644978
    },
    [Symbol(skip-override)]: true,
    [Symbol(fastify.display-name)]: '@fastify/mongodb',
    [Symbol(plugin-meta)]: { fastify: '4.x', name: '@fastify/mongodb' }
  }
}

from fastify-mongodb.

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.