winstonjs / winston-mongodb

A MongoDB transport for winston
https://github.com/winstonjs/winston-mongodb
296 stars 125 forks source link

Load balancer mode requires driver version 4+ #201

Open RubenatorX opened 2 years ago

RubenatorX commented 2 years ago

So, due to a change in mongodb atlas server, I've had to upgrade the mongodb driver to 4.1+ (currently 4.1.4), but, when I try to use windston-mongodb after that update I get:

{
  level: 'trace',
  db: 'mongodb+srv://***/***?retryWrites=true&w=majority',
  collection: 'server_logs',
  options: { useNewUrlParser: true, useUnifiedTopology: true }
}
winston-mongodb: error initialising logger MongoParseError: Load balancer mode requires driver version 4+
    at QueryReqWrap.callback (***\project\node_modules\winston-mongodb\node_modules\mongodb\lib\core\uri_parser.js:111:27)
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:212:10)
    at QueryReqWrap.callbackTrampoline (internal/async_hooks.js:130:17)

Does this package not support driver 4.1+? or do I just have something misconfigured?

asdfdelta commented 2 years ago

Did you ever solve this?

RubenatorX commented 2 years ago

Did you ever solve this?

nope

asdfdelta commented 2 years ago

@RubenatorX I found the issue. The package is using Mongoose v5, it needs to upgrade to v6 in order to take advantage of the v4 driver from Mongodb.

I ended up copying the index.js and put it in a separate file at my root. Then installed the latest Mongoose and fastify-plugin, require('./newfilelocation.js') instead of the package and it seems to work great so far. A shame these guys don't maintain any of these packages.

RubenatorX commented 2 years ago

@RubenatorX I found the issue. The package is using Mongoose v5, it needs to upgrade to v6 in order to take advantage of the v4 driver from Mongodb.

I ended up copying the index.js and put it in a separate file at my root. Then installed the latest Mongoose and fastify-plugin, require('./newfilelocation.js') instead of the package and it seems to work great so far. A shame these guys don't maintain any of these packages.

@asdfdelta Ew. But ty haha. Not sure if I will try that or just handle error reporting/logging with something else

asdfdelta commented 2 years ago

@RubenatorX I thought briefly about making a 3rd package and trying to keep that up to date, but then https://xkcd.com/927/

If you take that plunge, let me know so I can import your package lol

wbt commented 2 years ago

A shame these guys don't maintain any of these packages.

To be clear, there is zero funding to do so and as one of the most active maintainers these days, I don't currently use the Mongo driver so I don't have a lot of familiarity or incentive to dive into the tech and gain it. https://xkcd.com/2347/ is a little more on the nose here...

asdfdelta commented 2 years ago

That's why we create issues to help you guys out. Just updating the package.json to use the v6 adapter of Mongoose will solve this issue.

wbt commented 2 years ago

Just updating the package.json to use the v6 adapter of Mongoose will solve this issue.

Useful to know and the first time it's been said, but there's also backwards compatibility testing & verification that this doesn't break existing code. That's real work and hard for me specifically as I'm not currently a user of the mongoDB module.

asdfdelta commented 1 year ago

https://mongoosejs.com/docs/migrating_to_6.html

I suppose there might be issues there, yeah. It's a shame you created something that cannot ever be updated, could in the very least open up the PRs for review or allow someone else to take it over.

wbt commented 1 year ago

The project is open to PRs and any submitted PRs are open to anyone testing and reviewing them to say what they found.

1986webdeveloper commented 1 year ago

So, due to a change in mongodb atlas server, I've had to upgrade the mongodb driver to 4.1+ (currently 4.1.4), but, when I try to use windston-mongodb after that update I get:

{
  level: 'trace',
  db: 'mongodb+srv://***/***?retryWrites=true&w=majority',
  collection: 'server_logs',
  options: { useNewUrlParser: true, useUnifiedTopology: true }
}
winston-mongodb: error initialising logger MongoParseError: Load balancer mode requires driver version 4+
    at QueryReqWrap.callback (***\project\node_modules\winston-mongodb\node_modules\mongodb\lib\core\uri_parser.js:111:27)
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:212:10)
    at QueryReqWrap.callbackTrampoline (internal/async_hooks.js:130:17)

Does this package not support driver 4.1+? or do I just have something misconfigured?

Hello is it resolved ? because I m still facing issue Even I upgraded my mongoose version from v5 to v6

DABH commented 1 year ago

We updated to the latest version of mongoose on master, but we still need help upgrading to the latest mongodb package, see https://github.com/winstonjs/winston-mongodb/pull/223. If anyone is willing to step up and volunteer to fix this, it would be a huge help and would likely solve this and several related issues on the project.

klemensz commented 1 year ago

If anyone is willing to step up and volunteer to fix this

You mean because of the failing unit tests?

DABH commented 1 year ago

Yes