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
Use MongoClient.connect() instead of authenticate() if user provides URI to avoid Db.prototype.authenticate deprecated #5304
Comments
+1 |
1 similar comment
+1 |
+1 |
+1 |
yup looks like it only happens once you actually touch the db to do some operation (like a write): I created a user in the admin database called const mongoose = require('mongoose');
const co = require('co');
mongoose.Promise = global.Promise;
const GITHUB_ISSUE = `gh-5304`;
exec()
.then(() => {
console.log('successfully ran program');
process.exit(0);
})
.catch(error => {
console.error(`Error: ${ error }\n${ error.stack }`);
});
function exec() {
return co(function*() {
const db = mongoose.connect(`mongodb://gh_5304:gh_5304@localhost:27017/${ GITHUB_ISSUE }?authSource=admin`);
const schema = new mongoose.Schema({ name: String });
const Model = db.model('Model', schema);
const doc = yield Model.create({ name: 'Test' });
});
} Log output:
I'll mark this as a "bug", although tbh I'm not sure what I would describe this as. It's definitely a warning that should be heeded... |
The Re: the warning, this is something mongoose will have to carefully work around because that is the only way mongoose auth works right now. Even if you specify credentials in MongoClient.connect(), mongoose will still call |
Until 4.11, I wouldn't worry about this warning. To the best of my knowledge, MongoDB 3.6 and MongoDB driver 3.0 are unlikely to be released until much later this year and these changes will not require any end user changes. |
Thanks @varunjayaraman @vkarpov15 for your detailed answers ;) |
Does anyone know of a way to disable/hide this message? I keep seeing it come up when I spawn a process and it's getting on my nerves! 😅 |
I have same issue. |
I have also same issue. I don't know should i use mongoose or not. |
+1 |
the same issue here |
+1 |
+1 |
if you want to turn off warnings from the mongodb driver until 4.11, you can try using the steps here and use the underlying client from mongoose to set the logger: http://mongodb.github.io/node-mongodb-native/2.2/reference/management/logging/ otherwise you will be fine and the problem should be resolved in |
+1 |
const mongoose = require('mongoose'); var Scheme = mongoose.Schema({ var BlogPost = require("./models/mongodb.js"); //create new model post.save(function (err) { error: node .\index.js(node:2604) DeprecationWarning: Mongoose: mpromise (mongoose's de |
Which MongoDB and Mongoose version shall I use to avoid this error? |
this is bug right ? |
I am getting the same issue. MongoDB shell version v3.4.2 |
"mongoose": "~4.10.2", is work! |
Ok now I have removed node_module folders and changed package.json to use fixed older version "mongoose":"4.10.2". After npm install, the warning message is gone:
|
Yes, I'm waiting for bug fixes maybe a next version |
please do not just comment |
as for your issue @msaiganesh that seams to be a separate issue related to your db authentication. Can you please open up a separate issue? |
+2 (for me and my coworker) |
"mongoose": "^4.10.4" I'm getting this error also - I take it it's just a warning message as opposed to a bug, and doesn't prevent me from continuing? |
Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials. I'm trying to connect to mlab database with mongoose. I have tried installing older versions of mongoose. I keep getting this error when I run npm start on my MEAN app. I can't start the app. Can anyone help? |
Please read the issue in full before sending asking an already answered question and inadvertently sending an email to everyone who has subscribed to updates on this issue. |
I wonder how you solved it @JonathanBristow |
I this is my connection code:
and I got this warning: |
@Thinkdiff ... it's a |
I'm locking this issue temporarily to prevent continued spam. There will be an option that will shut off this warning in 4.11, which will be released this week barring any unforeseen delays. There is no way to bypass this warning in 4.10.x. Thank you for your patience. |
I'm using a connection method like :
... as indicated in the docs, but receiving the following warning on NodeJS console :
(I get an authentication failure if I omit
?authSource=admin
)Is this normal at this stage (do we need to wait for a next mongoose release ?),
or what should I change from now ?
Versions :
Node : 7.10.0
Mongoose : 4.10.3
MongoDB : 3.4
Thank you.
The text was updated successfully, but these errors were encountered: