{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/4659","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/4659/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/4659/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/4659/events","html_url":"https://github.com/Automattic/mongoose/issues/4659","id":185286088,"number":4659,"title":"mongoose.connect(uri, opts) does not return a promise","user":{"login":"niftylettuce","id":523141,"avatar_url":"https://avatars.githubusercontent.com/u/523141?v=3","gravatar_id":"","url":"https://api.github.com/users/niftylettuce","html_url":"https://github.com/niftylettuce","followers_url":"https://api.github.com/users/niftylettuce/followers","following_url":"https://api.github.com/users/niftylettuce/following{/other_user}","gists_url":"https://api.github.com/users/niftylettuce/gists{/gist_id}","starred_url":"https://api.github.com/users/niftylettuce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niftylettuce/subscriptions","organizations_url":"https://api.github.com/users/niftylettuce/orgs","repos_url":"https://api.github.com/users/niftylettuce/repos","events_url":"https://api.github.com/users/niftylettuce/events{/privacy}","received_events_url":"https://api.github.com/users/niftylettuce/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-26T03:05:39Z","updated_at":"2016-10-26T03:07:52Z","closed_at":null,"body":"when passing two arguments to `mongoose.connect` and expecting a promise to be returned, there is simply no promise returned and an error is thrown\r\n\r\nfor example:\r\n\r\n```js\r\nawait mongoose.connect(config.mongodb, config.mongodbOptions);\r\n```\r\n\r\nwill throw the error\r\n\r\n```\r\nTypeError: this.$opPromise.then is not a function\r\n    at MongooseThenable.then (/Users/nexus/Public/crocodile/node_modules/mongoose/lib/index.js:785:26)\r\n    at process._tickDomainCallback (internal/process/next_tick.js:129:7)\r\n    at Module.runMain (module.js:606:11)\r\n    at run (bootstrap_node.js:394:7)\r\n    at startup (bootstrap_node.js:149:9)\r\n    at bootstrap_node.js:509:3\r\n```\r\n\r\nbut without the second argument, it does not throw the error\r\n\r\n```\r\nawait mongoose.connect(config.mongodb);\r\n```\r\n\r\nworks fine\r\n\r\ncc @vkarpov15 "},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/256238124","html_url":"https://github.com/Automattic/mongoose/issues/4659#issuecomment-256238124","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/4659","id":256238124,"user":{"login":"niftylettuce","id":523141,"avatar_url":"https://avatars.githubusercontent.com/u/523141?v=3","gravatar_id":"","url":"https://api.github.com/users/niftylettuce","html_url":"https://github.com/niftylettuce","followers_url":"https://api.github.com/users/niftylettuce/followers","following_url":"https://api.github.com/users/niftylettuce/following{/other_user}","gists_url":"https://api.github.com/users/niftylettuce/gists{/gist_id}","starred_url":"https://api.github.com/users/niftylettuce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niftylettuce/subscriptions","organizations_url":"https://api.github.com/users/niftylettuce/orgs","repos_url":"https://api.github.com/users/niftylettuce/repos","events_url":"https://api.github.com/users/niftylettuce/events{/privacy}","received_events_url":"https://api.github.com/users/niftylettuce/received_events","type":"User","site_admin":false},"created_at":"2016-10-26T03:07:52Z","updated_at":"2016-10-26T03:07:52Z","body":"it looks like the alternate solution until this is fixed is to append the options to your URI such as\r\n\r\n`mongodb://db1.example.net,db2.example.net:2500/?replicaSet=test&connectTimeoutMS=300000`\r\n\r\nhttps://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options"}}
{"actor":{"display_login":"niftylettuce"}}