{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/4260","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/4260/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/4260/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/4260/events","html_url":"https://github.com/Automattic/mongoose/issues/4260","id":162074153,"number":4260,"title":"strange issue with mongoose and cloning","user":{"login":"amit777","id":2703309,"avatar_url":"https://avatars.githubusercontent.com/u/2703309?v=3","gravatar_id":"","url":"https://api.github.com/users/amit777","html_url":"https://github.com/amit777","followers_url":"https://api.github.com/users/amit777/followers","following_url":"https://api.github.com/users/amit777/following{/other_user}","gists_url":"https://api.github.com/users/amit777/gists{/gist_id}","starred_url":"https://api.github.com/users/amit777/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amit777/subscriptions","organizations_url":"https://api.github.com/users/amit777/orgs","repos_url":"https://api.github.com/users/amit777/repos","events_url":"https://api.github.com/users/amit777/events{/privacy}","received_events_url":"https://api.github.com/users/amit777/received_events","type":"User","site_admin":false},"labels":[{"id":31695135,"url":"https://api.github.com/repos/Automattic/mongoose/labels/help","name":"help","color":"FFFFFF","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-06-24T04:32:07Z","updated_at":"2016-12-03T09:52:42Z","closed_at":"2016-06-25T19:00:07Z","body":"(node 6.2.2, mongoose 4.5.2, node-sassl 3.7.0 works)\nWhen updated my node-sass to 3.8.0, i get the following mongoose error.  It seems like node-sass change something with the way it deals with objects by doing a clone of some sort.  I'm not sure if this a bug with node-sass or if the change in node-sass has exposed a bug in mongoose:  Here is a link to the issue (it has a stack trace in it).\n\nhttps://github.com/sass/node-sass/issues/1606\n\nStack trace is here for simplicity:\n\n```\nTypeError: Cannot read property 'states' of undefined\n    at model.Document.$__shouldModify (/opt/app/node_modules/mongoose/lib/document.js:765:35)\n    at model.Document.$__set (/opt/app/node_modules/mongoose/lib/document.js:785:27)\n    at model.Document.set (/opt/app/node_modules/mongoose/lib/document.js:705:10)\n    at model.Object.defineProperty.set [as domainname] (/opt/app/node_modules/mongoose/lib/document.js:1712:25)\n    at assignValue (/opt/app/node_modules/lodash._baseclone/index.js:758:17)\n    at /opt/app/node_modules/lodash._baseclone/index.js:863:5\n    at arrayEach (/opt/app/node_modules/lodash._baseclone/index.js:164:9)\n    at baseClone (/opt/app/node_modules/lodash._baseclone/index.js:858:3)\n    at /opt/app/node_modules/lodash._baseclone/index.js:863:30\n    at arrayEach (/opt/app/node_modules/lodash._baseclone/index.js:164:9)\n    at baseClone (/opt/app/node_modules/lodash._baseclone/index.js:858:3)\n    at /opt/app/node_modules/lodash._baseclone/index.js:863:30\n    at arrayEach (/opt/app/node_modules/lodash._baseclone/index.js:164:9)\n    at baseClone (/opt/app/node_modules/lodash._baseclone/index.js:858:3)\n    at /opt/app/node_modules/lodash._baseclone/index.js:863:30\n    at arrayEach (/opt/app/node_modules/lodash._baseclone/index.js:164:9)\n    at baseClone (/opt/app/node_modules/lodash._baseclone/index.js:858:3)\n    at /opt/app/node_modules/lodash._baseclone/index.js:863:30\n    at arrayEach (/opt/app/node_modules/lodash._baseclone/index.js:164:9)\n    at baseClone (/opt/app/node_modules/lodash._baseclone/index.js:858:3)\n    at /opt/app/node_modules/lodash._baseclone/index.js:863:30\n    at arrayEach (/opt/app/node_modules/lodash._baseclone/index.js:164:9)\n    at baseClone (/opt/app/node_modules/lodash._baseclone/index.js:858:3)\n    at /opt/app/node_modules/lodash._baseclone/index.js:863:30\n    at arrayEach (/opt/app/node_modules/lodash._baseclone/index.js:164:9)\n    at baseClone (/opt/app/node_modules/lodash._baseclone/index.js:858:3)\n    at /opt/app/node_modules/lodash._baseclone/index.js:863:30\n    at arrayEach (/opt/app/node_modules/lodash._baseclone/index.js:164:9)\n    at baseClone (/opt/app/node_modules/lodash._baseclone/index.js:858:3)\n    at /opt/app/node_modules/lodash._baseclone/index.js:863:30\n    at arrayEach (/opt/app/node_modules/lodash._baseclone/index.js:164:9)\n    at baseClone (/opt/app/node_modules/lodash._baseclone/index.js:858:3)\n    at cloneDeep (/opt/app/node_modules/lodash.clonedeep/index.js:28:10)\n    at getOptions (/opt/app/node_modules/node-sass/lib/index.js:175:17)\n    at Object.module.exports.render (/opt/app/node_modules/node-sass/lib/index.js:268:17)\n    at /opt/app/node_modules/email-templates/lib/template-manager.js:124:10\n    at Promise._execute (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/debuggability.js:272:9)\n    at Promise._resolveFromExecutor (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:475:18)\n    at new Promise (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:77:14)\n    at renderSass (/opt/app/node_modules/email-templates/lib/template-manager.js:123:10)\n    at /opt/app/node_modules/email-templates/lib/template-manager.js:63:22\n    at Promise._execute (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/debuggability.js:272:9)\n    at Promise._resolveFromExecutor (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:475:18)\n    at new Promise (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:77:14)\n    at render (/opt/app/node_modules/email-templates/lib/template-manager.js:45:10)\n    at renderFile (/opt/app/node_modules/email-templates/lib/util.js:53:38)\n    at /opt/app/node_modules/email-templates/lib/email-template.js:200:38\n    at Promise._execute (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/debuggability.js:272:9)\n    at Promise._resolveFromExecutor (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:475:18)\n    at new Promise (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:77:14)\n    at EmailTemplate._renderStyle (/opt/app/node_modules/email-templates/lib/email-template.js:188:14)\n    at /opt/app/node_modules/email-templates/lib/email-template.js:146:97\n    at tryCatcher (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:504:31)\n    at Promise._settlePromise (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:561:18)\n    at Promise._settlePromise0 (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:606:10)\n    at Promise._settlePromises (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:685:18)\n    at Promise._fulfill (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:630:18)\n    at Promise._resolveCallback (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:425:57)\n    at Promise._settlePromiseFromHandler (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:516:17)\n    at Promise._settlePromise (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:561:18)\n    at Promise._settlePromise0 (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:606:10)\n    at Promise._settlePromises (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:685:18)\n    at Promise._fulfill (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:630:18)\n    at Promise._resolveCallback (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:425:57)\n    at Promise._settlePromiseFromHandler (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:516:17)\n    at Promise._settlePromise (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:561:18)\n    at Promise._settlePromise0 (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:606:10)\n    at Promise._settlePromises (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:685:18)\n    at Promise._fulfill (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:630:18)\n    at MappingPromiseArray.PromiseArray._resolve (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise_array.js:125:19)\n    at MappingPromiseArray._promiseFulfilled (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/map.js:97:18)\n    at Promise._settlePromise (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:566:26)\n    at Promise._settlePromise0 (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:606:10)\n    at Promise._settlePromises (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:685:18)\n    at Promise._fulfill (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:630:18)\n    at Promise._resolveCallback (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:425:57)\n    at Promise._settlePromiseFromHandler (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:516:17)\n    at Promise._settlePromise (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:561:18)\n    at Promise._settlePromise0 (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:606:10)\n    at Promise._settlePromises (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:685:18)\n    at Promise._fulfill (/opt/app/node_modules/email-templates/node_modules/bluebird/js/release/promise.js:630:18)\n    at /opt/app/node_modules/email-templates/node_modules/bluebird/js/release/nodeback.js:42:21\n```\n"},"comment":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/comments/264629403","html_url":"https://github.com/Automattic/mongoose/issues/4260#issuecomment-264629403","issue_url":"https://api.github.com/repos/Automattic/mongoose/issues/4260","id":264629403,"user":{"login":"simonepri","id":3505087,"avatar_url":"https://avatars.githubusercontent.com/u/3505087?v=3","gravatar_id":"","url":"https://api.github.com/users/simonepri","html_url":"https://github.com/simonepri","followers_url":"https://api.github.com/users/simonepri/followers","following_url":"https://api.github.com/users/simonepri/following{/other_user}","gists_url":"https://api.github.com/users/simonepri/gists{/gist_id}","starred_url":"https://api.github.com/users/simonepri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonepri/subscriptions","organizations_url":"https://api.github.com/users/simonepri/orgs","repos_url":"https://api.github.com/users/simonepri/repos","events_url":"https://api.github.com/users/simonepri/events{/privacy}","received_events_url":"https://api.github.com/users/simonepri/received_events","type":"User","site_admin":false},"created_at":"2016-12-03T09:52:42Z","updated_at":"2016-12-03T09:52:42Z","body":"I don't know if could be useful but the problem seems to be still here (using _.CloneDeep()):\r\n\r\n\"lodash\": \"^4.17.2\"\r\n\"mongoose\": \"^4.7.1\"\r\n\r\n```\r\nTypeError: Cannot read property 'states' of undefined\r\n    at model.Document.$__shouldModify (\\node_modules\\mongoose\\lib\\document.js:802:56)\r\n    at model.Document.$__set (\\node_modules\\mongoose\\lib\\document.js:842:27)\r\n    at model.Document.set (\\node_modules\\mongoose\\lib\\document.js:758:10)\r\n    at model.Object.defineProperty.set [as supplier_id] (\\node_modules\\mongoose\\lib\\document.js:1787:25)\r\n    at baseAssignValue (\\node_modules\\lodash\\lodash.js:2599:21)\r\n    at assignValue (\\node_modules\\lodash\\lodash.js:2515:9)\r\n    at \\node_modules\\lodash\\lodash.js:2721:9\r\n    at arrayEach (\\node_modules\\lodash\\lodash.js:537:11)\r\n    at baseClone (\\node_modules\\lodash\\lodash.js:2715:7)\r\n    at \\node_modules\\lodash\\lodash.js:2721:34\r\n    at arrayEach (\\node_modules\\lodash\\lodash.js:537:11)\r\n    at baseClone (\\node_modules\\lodash\\lodash.js:2715:7)\r\n    at \\node_modules\\lodash\\lodash.js:2721:34\r\n    at arrayEach (\\node_modules\\lodash\\lodash.js:537:11)\r\n    at baseClone (\\node_modules\\lodash\\lodash.js:2715:7)\r\n    at \\node_modules\\lodash\\lodash.js:2721:34\r\n```"}}
{"actor":{"display_login":"simonepri"}}