Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix "reconnectTries is not supported" error #11928

Closed
2 tasks done
ace-n opened this issue Jun 13, 2022 · 1 comment · Fixed by #11930
Closed
2 tasks done

docs: fix "reconnectTries is not supported" error #11928

ace-n opened this issue Jun 13, 2022 · 1 comment · Fixed by #11930
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.

Comments

@ace-n
Copy link

ace-n commented Jun 13, 2022

Prerequisites

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

Mongoose version

6.3.8

Node.js version

14.19.1

MongoDB server version

N/A

Description

The Mongoose docs mention a property called reconnectTries.

This used to work fine with the mongodb NPM package for 3.x versions, but fails on the latest versions of mongodb (4.x) that Mongoose itself uses.

Steps to Reproduce

Run this code:

const mongoose = require('mongoose')
const mongoURI = "mongodb://127.0.0.1:8080/"

const connectToMongoDB = async () => {
    await mongoose.connect(mongoURI, {
        useNewUrlParser: true,
        connectTimeoutMS: 2000,
        reconnectTries: 5,
        useUnifiedTopology: true
    })
};

connectToMongoDB();

Actual Behavior

I get an error that looks like this:

(node:22113) UnhandledPromiseRejectionWarning: MongoParseError: option reconnecttries is not supported
    at parseOptions (<ROOTDIR>/node_modules/mongodb/lib/connection_string.js:280:15)
    at new MongoClient (<ROOTDIR>/node_modules/mongodb/lib/mongo_client.js:62:63)
    at <ROOTDIR>/node_modules/mongoose/lib/connection.js:784:16
    at new Promise (<anonymous>)
    at NativeConnection.Connection.openUri (<ROOTDIR>/node_modules/mongoose/lib/connection.js:781:19)
    at <ROOTDIR>/node_modules/mongoose/lib/index.js:344:10
    at <ROOTDIR>/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (<ROOTDIR>/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (<ROOTDIR>/node_modules/mongoose/lib/index.js:1182:10)

Expected Behavior

Either Mongoose should be updated to support the reconnectTries property, or references to it should be removed from the docs and marked as deprecated in public documentation.

@ace-n ace-n changed the title Fix "reconnectTries is not supported" error docs: fix "reconnectTries is not supported" error Jun 13, 2022
@Uzlopak
Copy link
Collaborator

Uzlopak commented Jun 14, 2022

Created PR #11930
Please have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants