Skip to content

Conversation

@Sakibdevlekar
Copy link

Fix Deprecation Warning for MongoDB URL Parsing in winston-mongodb

Issue
The recent Node.js version 20 and MongoDB driver updates have introduced a deprecation warning in winston-mongodb due to the use of deprecated APIs in the MongoDB driver.

Changes Made
Updated the MongoDB URL parsing in winston-mongodb to resolve the deprecation warning.
Used the latest MongoDB driver version to ensure compatibility and compliance with Node.js updates.

Additional Notes
Tested the changes locally with Node.js version 20 and verified that the deprecation warning is no longer triggered.
Ensured backward compatibility with previous Node.js and MongoDB versions.
Updated dependencies and added necessary documentation or comments related to the fix.

Reviewer Instructions:
Please review the changes and ensure compatibility with different Node.js and MongoDB versions. Verify that the deprecation warning is resolved and no new issues are introduced. Any feedback or suggestions are highly appreciated.
@DABH

@DABH
Copy link
Contributor

DABH commented Sep 25, 2024

@Sakibdevlekar We just released winston-mongodb v6.0.0, please let us know if this issue still persists and if we need something like this PR in the new major version. If we don't hear anything in the next week or two we'll close out this PR and assume that the other major version changes ended up fixing this issue.

@KeithGillette
Copy link

I'm not entirely sure these are the same warnings this PR is meant to fix or were reported in issue #218 reported, but I am see deprecation warnings under NodeJS v20.17.0 and [email protected] and [email protected]:

(node:8519) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
    at emitWarning (/Path/To/node_modules/mongodb/src/utils.ts:1020:18)
    at parseOptions (/Path/To/node_modules/mongodb/src/connection_string.ts:384:20)
    at new MongoClient (/Path/To/node_modules/mongodb/src/mongo_client.ts:374:34)
    at Function.connect (/Path/To/node_modules/mongodb/src/mongo_client.ts:713:20)
    at connectToDatabase (/Path/To/node_modules/winston-mongodb/lib/winston-mongodb.js:136:32)
    at new exports.MongoDB (/Path/To/node_modules/winston-mongodb/lib/winston-mongodb.js:151:5)
    at /Path/To/deploy/applications/server/main.js:3510:29
    at Object.<anonymous> (/Path/To/deploy/applications/server/main.js:25338:12)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1416:10)

(node:8519) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version
    at emitWarning (/Path/To/node_modules/mongodb/src/utils.ts:1020:18)
    at parseOptions (/Path/To/node_modules/mongodb/src/connection_string.ts:384:20)
    at new MongoClient (/Path/To/node_modules/mongodb/src/mongo_client.ts:374:34)
    at Function.connect (/Path/To/node_modules/mongodb/src/mongo_client.ts:713:20)
    at connectToDatabase (/Path/To/node_modules/winston-mongodb/lib/winston-mongodb.js:136:32)
    at new exports.MongoDB (/Path/To/node_modules/winston-mongodb/lib/winston-mongodb.js:151:5)
    at /Path/To/deploy/applications/server/main.js:3510:29
    at Object.<anonymous> (/Path/To/deploy/applications/server/main.js:25338:12)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1416:10)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants