Mongoose: Cannot read property '$isSingleNested' of undefined

Created on 16 Aug 2016  路  7Comments  路  Source: Automattic/mongoose

I suspect this is an issue with mongoose.
I just upgraded from 4.4.2 to 4.5.9 and I get the following error:

info: ERROR IN RECEIVE MIDDLEWARE: TypeError: Cannot read property '$isSingleNested' of undefined

I believe my code that's causing the issue is:

Model.update({ _id: foo._id }, {
    $inc: { "foo.bar.rofl": count },
    $set: {
        "foo.bar.last_message": Date.now(),
        "foo.stix": err || "ok"
    }
}, err => done(err));

Any ideas?

Most helpful comment

Same here, since 4.5.9 (4.5.8 is fine).
Having a look at the changelog, the culprit might be https://github.com/Automattic/mongoose/issues/4369

All 7 comments

I am getting the same error upgrading from 4.4.10 to 4.5.9

Same error on 4.5.8:

TypeError: Cannot read property '$isSingleNested' of undefined
    at applyTimestampsToChildren (*project-path*/node_modules/mongoose/lib/schema.js:865:56)
    at Query.<anonymous> (*project-path*/node_modules/mongoose/lib/schema.js:810:7)
    at next (*project-path*/node_modules/mongoose/node_modules/kareem/index.js:82:14)
    at Kareem.execPre (*project-path*/node_modules/mongoose/node_modules/kareem/index.js:99:3)
    at Kareem.wrap (*project-path*/node_modules/mongoose/node_modules/kareem/index.js:231:8)
    at Query._findOneAndUpdate (*project-path*/node_modules/mongoose/node_modules/kareem/index.js:271:11)
    at Query.findOneAndUpdate (*project-path*/node_modules/mongoose/lib/query.js:1667:15)
    at *project-path*/node_modules/mongoose/lib/query.js:2230:21
    at new Promise.ES6 (*project-path*/node_modules/mongoose/lib/promise.js:45:3)
    at Query.exec (*project-path*/node_modules/mongoose/lib/query.js:2223:10)
    at Query.then (*project-path*/node_modules/mongoose/lib/query.js:2253:15)
    at next (*project-path*/node_modules/co/index.js:100:51)
    at onFulfilled (*project-path*/node_modules/co/index.js:69:7)
    ...

4.5.7 works!

Another trace:

Unhandled rejection TypeError: Cannot read property '$isSingleNested' of undefined
    at applyTimestampsToChildren (/srv/player/node_modules/mongoose/lib/schema.js:865:56)
    at Query.<anonymous> (/srv/player/node_modules/mongoose/lib/schema.js:816:7)
    at next (/srv/player/node_modules/mongoose/node_modules/kareem/index.js:82:14)
    at Kareem.execPre (/srv/player/node_modules/mongoose/node_modules/kareem/index.js:99:3)
    at Kareem.wrap (/srv/player/node_modules/mongoose/node_modules/kareem/index.js:231:8)
    at Query._execUpdate (/srv/player/node_modules/mongoose/node_modules/kareem/index.js:271:11)
    at Query.update (/srv/player/node_modules/mongoose/lib/query.js:2189:17)
    at Function.update (/srv/player/node_modules/mongoose/lib/model.js:2056:13)
    at Function.tryCatcher (/srv/player/node_modules/bluebird/js/release/util.js:16:23)
    at Function.ret (eval at <anonymous> (/srv/player/node_modules/bluebird/js/release/promisify.js:205:1), <anonymous>:14:23)
    at Function.schema.statics.updateAsync (/srv/player/player/player/models/behaviors/bluebird-promises.js:33:43)
    at /srv/player/player/player/modules/media.js:147:29
    at tryCatcher (/srv/player/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/srv/player/node_modules/bluebird/js/release/promise.js:504:31)
    at Promise._settlePromise (/srv/player/node_modules/bluebird/js/release/promise.js:561:18)
    at Promise._settlePromise0 (/srv/player/node_modules/bluebird/js/release/promise.js:606:10)
    at Promise._settlePromises (/srv/player/node_modules/bluebird/js/release/promise.js:685:18)
    at Promise._fulfill (/srv/player/node_modules/bluebird/js/release/promise.js:630:18)
    at /srv/player/node_modules/bluebird/js/release/nodeback.js:42:21
    at Query.<anonymous> (/srv/player/node_modules/mongoose/lib/model.js:3324:16)
    at /srv/player/node_modules/mongoose/node_modules/kareem/index.js:259:21
    at /srv/player/node_modules/mongoose/node_modules/kareem/index.js:127:16

Same here, since 4.5.9 (4.5.8 is fine).
Having a look at the changelog, the culprit might be https://github.com/Automattic/mongoose/issues/4369

Same here since 4.5.9
Happens only with $set of nested fields as the above

$set: { "foo.bar.last_message": Date.now(), "foo.stix": err || "ok" }

part

Duplicate of #4418, will push a fix tomorrow

Was this page helpful?
0 / 5 - 0 ratings