{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/2948","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/2948/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/2948/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/2948/events","html_url":"https://github.com/Automattic/mongoose/issues/2948","id":72274156,"number":2948,"title":"Document returned from promise won't save","user":{"login":"Jks15063","id":1919781,"avatar_url":"https://avatars.githubusercontent.com/u/1919781?v=3","gravatar_id":"","url":"https://api.github.com/users/Jks15063","html_url":"https://github.com/Jks15063","followers_url":"https://api.github.com/users/Jks15063/followers","following_url":"https://api.github.com/users/Jks15063/following{/other_user}","gists_url":"https://api.github.com/users/Jks15063/gists{/gist_id}","starred_url":"https://api.github.com/users/Jks15063/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jks15063/subscriptions","organizations_url":"https://api.github.com/users/Jks15063/orgs","repos_url":"https://api.github.com/users/Jks15063/repos","events_url":"https://api.github.com/users/Jks15063/events{/privacy}","received_events_url":"https://api.github.com/users/Jks15063/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/mongoose/labels/can't%20reproduce","name":"can't reproduce","color":"bfdadc"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/Automattic/mongoose/milestones/41","html_url":"https://github.com/Automattic/mongoose/milestones/4.0.5","labels_url":"https://api.github.com/repos/Automattic/mongoose/milestones/41/labels","id":1103714,"number":41,"title":"4.0.5","description":"","creator":{"login":"vkarpov15","id":1620265,"avatar_url":"https://avatars.githubusercontent.com/u/1620265?v=3","gravatar_id":"","url":"https://api.github.com/users/vkarpov15","html_url":"https://github.com/vkarpov15","followers_url":"https://api.github.com/users/vkarpov15/followers","following_url":"https://api.github.com/users/vkarpov15/following{/other_user}","gists_url":"https://api.github.com/users/vkarpov15/gists{/gist_id}","starred_url":"https://api.github.com/users/vkarpov15/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkarpov15/subscriptions","organizations_url":"https://api.github.com/users/vkarpov15/orgs","repos_url":"https://api.github.com/users/vkarpov15/repos","events_url":"https://api.github.com/users/vkarpov15/events{/privacy}","received_events_url":"https://api.github.com/users/vkarpov15/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":4,"state":"open","created_at":"2015-05-10T16:14:13Z","updated_at":"2015-06-01T18:49:10Z","due_on":"2015-06-05T04:00:00Z","closed_at":null},"comments":2,"created_at":"2015-04-30T20:34:25Z","updated_at":"2015-06-01T18:49:10Z","closed_at":"2015-06-01T18:49:10Z","body":"Issue only crops up after upgrade to version 4.  I can consistently downgrade to 3.8 and watch the save start working, and upgrade to 4 and see it stop working.\r\n\r\n````\r\nfunction findADoc() {\r\n    return newTest.findOne({}).exec();\r\n}\r\n\r\nfindADoc()\r\n.then(function(doc) {\r\n    console.log(err, doc);\r\n    doc.set('foo', 'wut');\r\n    doc.save(function(error) {\r\n        console.log('->', error);\r\n    });\r\n});\r\n```\r\n\r\nTurned on logging, `.then` is hit, doc is logged to console, but save is never fired.\r\nSomething to do with being passed through a promise chain, documents returned to a callback will save.\r\nFor example:\r\n```\r\nnewTest.findOne({}, function(err, doc) {\r\n    doc.set('foo', 'wut');\r\n    doc.save(function(error) {\r\n        console.log('->', error);\r\n    });\r\n});\r\n```\r\nThe above still works as expected.\r\n\r\nTried various combinations of wrapping it with Q:\r\n`return Q(newTest.findOne({}).exec());`\r\n`Q.when(findADoc)...`\r\nI always get the doc, but save does not fire."},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/107669359","html_url":"https://github.com/Automattic/mongoose/issues/2948#issuecomment-107669359","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/2948","id":107669359,"user":{"login":"vkarpov15","id":1620265,"avatar_url":"https://avatars.githubusercontent.com/u/1620265?v=3","gravatar_id":"","url":"https://api.github.com/users/vkarpov15","html_url":"https://github.com/vkarpov15","followers_url":"https://api.github.com/users/vkarpov15/followers","following_url":"https://api.github.com/users/vkarpov15/following{/other_user}","gists_url":"https://api.github.com/users/vkarpov15/gists{/gist_id}","starred_url":"https://api.github.com/users/vkarpov15/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkarpov15/subscriptions","organizations_url":"https://api.github.com/users/vkarpov15/orgs","repos_url":"https://api.github.com/users/vkarpov15/repos","events_url":"https://api.github.com/users/vkarpov15/events{/privacy}","received_events_url":"https://api.github.com/users/vkarpov15/received_events","type":"User","site_admin":false},"created_at":"2015-06-01T18:49:10Z","updated_at":"2015-06-01T18:49:10Z","body":"No activity for a while, please re-open if this is still an issue."}}