Closed d4rth-v4d3r closed 5 years ago
This is happening in my system as well. Has to do with #8223 It occurs when saving any record for me (at least records with a subdocument).
I got the same problem, upgrading from v5.6.11 to 5.7.5. Every time I try to save a document in one of my collections I get this error, but other collections work just fine. The problematic collection has subdocuments. I fixed my problem by going back to v5.6.11.
Same here, here is a repro:
'use strict';
const Promise = require('bluebird');
const mongoose = require('mongoose');
mongoose.Promise = Promise;
// DB
let connect = mongoose.connect('mongodb://localhost:27018/test', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
const ActivitySchema = new mongoose.Schema({
description: {
type: String,
required: true,
},
}, {
timestamps: true,
_id: false,
});
const RequestSchema = new mongoose.Schema({
name: {},
activity: ActivitySchema,
});
const Request = mongoose.model('Request', RequestSchema);
// Create test data
connect.then(async () => {
mongoose.connection.db.dropDatabase();
const request = await Request.create({
name: 'lol',
activity: {
description: 'title',
},
});
request.activity.set({
description: 'foo',
})
// Will fail
await request.save();
// Log request
console.log(request);
});
~I initially thought it was due to the timestamp option but it appears this is more general~ It seems to work if I disable the timestamps option. Please tell me if that's another bug!
Works fine in 5.7.4, makes sense since the code was introduced in https://github.com/Automattic/mongoose/commit/327b47a1ee3e65abd2b09ced20d129a2dbd6e8ae
Error for me stems from lib/schema.js:1113 where this.isModified()
is called without arguments. However it seems that the isModified
function expects 2 arguments: paths
& modifiedPaths
. Hence the error. Regression seems to have been introduced in 5.7.5 as 5.7.4 works fine
Thanks for the repro script and sorry for the trouble, the fix will be in 5.7.6 :+1:
Thanks for the quick fix and thanks for being this reactive!
I got the same problem. Is it a bug? If not then can you share the solution
If you're before 5.7.6 then upgrade (the fix is there) otherwise open a new issue!
Getting same issue even though mine is "mongoose": "^6.6.5". can anyone pls share the solution
The solution was updating at the time. If this happens again, the as said earlier, you should open a new issue, so the maintainers see it better.
BUG
{ "name": "TypeError", "message": "Cannot read property 'split' of undefined", "stack": "TypeError: Cannot read property 'split' of undefined\n at SingleNested.Subdocument.isModified (/home/node/app/ne-route-droker-api/node_modules/mongoose/lib/types/subdocument.js:120:51)\n at SingleNested.<anonymous> (/home/node/app/ne-route-droker-api/node_modules/mongoose/lib/schema.js:1113:60)\n at callMiddlewareFunction (/home/node/app/ne-route-droker-api/node_modules/kareem/index.js:482:23)\n at SingleNested.next (/home/node/app/ne-route-droker-api/node_modules/kareem/index.js:58:7)\n at _next (/home/node/app/ne-route-droker-api/node_modules/kareem/index.js:106:10)\n at process.nextTick (/home/node/app/ne-route-droker-api/node_modules/kareem/index.js:507:38)\n at process._tickCallback (internal/process/next_tick.js:61:11)" }
My code was working like a charm and I update from 5.7.1 to 5.7.5 and suddenly this error start happening. I did not write any change in my code. I revert to version 5.7.1 and everything works again.
I built a Docker Image over Ubuntu 16.04.
Mongo 4.1 Node 10 LTS Mongoose version 5.7.5