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

Failure with mongoose v5.10 #4

Closed
mryellow opened this issue Aug 16, 2020 · 6 comments
Closed

Failure with mongoose v5.10 #4

mryellow opened this issue Aug 16, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@mryellow
Copy link
Contributor

Working: mongoose 5.9.29.

When updated to 5.10.0 the following error results:

340  const conn = _mongoose.connection;
     vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
341  return conn.openUri(uri, options, callback).then(() => _mongoose);
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
342};
ERROR: conn.openUri(...).then is not a function
 ├ Mongoose.connect @ /..../node_modules/mongoose/lib/index.js +339:47
 └ SYNTAX @     at /..../node_modules/@momsfriendlydevco/lock/index.js:51 +23
@mryellow mryellow added the bug Something isn't working label Aug 16, 2020
@TeleMediaCC
Copy link

TeleMediaCC commented Aug 17, 2020

same problem.

"mongoose": "=5.10.0"

 ERROR  conn.openUri(...).then is not a function

  TypeError: conn.openUri(...).then is not a function
  at Proxy.Mongoose.connect (node_modules/mongoose/lib/index.js:339:47)

@mryellow
Copy link
Contributor Author

Had a look in Mongoose and it appears a fix for a multiple-connections issue returned before promises were setup.

I imagine they'll push a hotfix before very long.

Automattic/mongoose#9335 (comment)

@mryellow
Copy link
Contributor Author

I only see lock.init() being called once in the project where this popped up.

Which I guess means any existing connection with this.readyState === STATES.connecting || this.readyState === STATES.connected must effectively be a singleton from npm caching the mongoose package.

Switching to createConnection as per https://mongoosejs.com/docs/connections.html#multiple_connections should do the trick.

@emanual4real
Copy link

Thank God I'm not crazy! Spent hours on this yesterday. Downgrading from 5.10.0 to 5.9.29 has resolved my issue.

@mryellow
Copy link
Contributor Author

Bumped the version on NPM to use createConnection(). Though will likely go back to using connect() when they fix mongoose.

mryellow added a commit that referenced this issue Aug 26, 2020
@mryellow
Copy link
Contributor Author

Mongoose 5.10.1 has a commit to patch this although not deployed to npm yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants