Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When I call connect
from mongoose
, it throws an exception
TypeError: Cannot read property '_promiseOrCallback' of undefined
at Mongoose.connect
If the current behavior is a bug, please provide the steps to reproduce.
Code:
const { connect } = require('mongoose');
async function main() {
try {
await connect(env.DB_CONNECTION_STRING, {
useNewUrlParser: true,
useUnifiedTopology: true,
user: env.DB_USER,
pass: env.DB_PWD,
});
}
catch (err) {
console.error(err);
}
}
main();
What is the expected behavior?
Mongoose create connect successfully
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: v12.18.4
Mongoose: v5.10.15
Mongodb: v4.4.1
Welcome @shhlkien
I can confirm that this is a bug, we'll fix this in 5.10.18.
Meanwhile, you can use mongoose.connect
instead of connect
to fix the issue you're facing.
const mongoose = require('mongoose');
async function main() {
try {
await mongoose.connect(env.DB_CONNECTION_STRING, {
useNewUrlParser: true,
useUnifiedTopology: true,
user: env.DB_USER,
pass: env.DB_PWD
});
}
catch (err) {
console.error(err);
}
}
main();
Ok. Thank you for fast reply