These are chat archives for Automattic/mongoose

31st
Jul 2018
Nathaniel Suchy
@nsuchy
Jul 31 2018 19:59
Did the way connection Uris are parsed suddenly change from 5.0.x to 5.2.x?

I have the following setup

// mongoose setup
mongoose.connect(process.env.MONGODB_URI);
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', () => {});

and get an error

> node ./bin/www

(node:2555) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
connection error: Error: Slash in host identifier
    at parseConnectionString (/Users/nathanielsuchy/Documents/control-panel/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js:219:15)
    at parseHandler (/Users/nathanielsuchy/Documents/control-panel/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js:129:14)
    at module.exports (/Users/nathanielsuchy/Documents/control-panel/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js:25:12)
    at deprecated (internal/util.js:70:15)
    at connect (/Users/nathanielsuchy/Documents/control-panel/node_modules/mongoose/node_modules/mongodb/lib/operations/mongo_client_ops.js:179:3)
    at connectOp (/Users/nathanielsuchy/Documents/control-panel/node_modules/mongoose/node_modules/mongodb/lib/operations/mongo_client_ops.js:283:3)
    at executeOperation (/Users/nathanielsuchy/Documents/control-panel/node_modules/mongoose/node_modules/mongodb/lib/utils.js:420:24)
    at MongoClient.connect (/Users/nathanielsuchy/Documents/control-panel/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js:168:10)
    at Promise (/Users/nathanielsuchy/Documents/control-panel/node_modules/mongoose/lib/connection.js:493:12)
    at new Promise (<anonymous>)
    at NativeConnection.Connection.openUri (/Users/nathanielsuchy/Documents/control-panel/node_modules/mongoose/lib/connection.js:490:19)
    at Mongoose.connect (/Users/nathanielsuchy/Documents/control-panel/node_modules/mongoose/lib/index.js:230:15)
    at Object.<anonymous> (/Users/nathanielsuchy/Documents/control-panel/app.js:20:10)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
and the following URI
mongodb://user:password@ds123456.mlab.com:12345/someRandomName
(some data psuedonymized for privacy)
  "dependencies": {
    "bcrypt-nodejs": "0.0.3",
    "body-parser": "^1.18.3",
    "connect-flash": "^0.1.1",
    "connect-mongo": "^2.0.1",
    "cookie-parser": "^1.4.3",
    "debug": "~2.6.9",
    "dotenv": "^6.0.0",
    "eslint": "^5.2.0",
    "eslint-config-google": "^0.9.1",
    "express": "~4.16.0",
    "express-session": "^1.15.6",
    "http-errors": "~1.6.2",
    "method-override": "^3.0.0",
    "mongoose": "^5.2.6",
    "morgan": "~1.9.0",
    "nodemon": "^1.18.3",
    "passport": "^0.4.0",
    "passport-local": "^1.0.0",
    "pug": "2.0.0-beta11"
  }
Nathaniel Suchy
@nsuchy
Jul 31 2018 20:06
PS /Users/nathanielsuchy/Documents/control-panel> node -v                                    
v10.7.0
PS /Users/nathanielsuchy/Documents/control-panel> npm -v                                     
6.2.0
My Node and NPM Versions for those who think it might be a version specific bug