Comments (9)
This indicates that the connection to the db could not be established, as the plugin never resolves.
from fastify-mongodb.
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.
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.
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.
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.
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.
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.
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.
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)
- fastify-mongodb is "eating" errors on register HOT 1
- this: Object is possibly 'undefined HOT 1
- TypeScript Example needed HOT 1
- Mongodb connection error HOT 19
- Fastify get route requires options? HOT 2
- Typescript: object is possibly undefined HOT 5
- Database Selection At Runtime HOT 4
- find() method returns events HOT 2
- Connection failes using Scalegrid.io HOT 5
- [email protected] is incompatible with newer version of [email protected]. HOT 2
- GCP Deploy using @fastify/mongodb HOT 3
- Mongodb find({}) error HOT 5
- Enable Dependabot HOT 7
- Consider re-exporting some (all?) types from mongodb HOT 1
- Update MongoDB v5 HOT 1
- Move MongoDB to peerDependencies HOT 14
- Pass variable to regex fails HOT 4
- Error Plugin did not start in time: '@fastify/mongodb'. You may have forgotten to call 'done' function or to resolve a Promise HOT 19
- onClose hook blocking main process HOT 7
- fastify.mongo.client.topology // TS2339: Property topology does not exist on type MongoClient HOT 1
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 fastify-mongodb.