-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongoose 5.7.5 Cannot read property 'split' of undefined #8251
Comments
This is happening in my system as well. Has to do with #8223 |
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);
});
Works fine in 5.7.4, makes sense since the code was introduced in 327b47a |
Error for me stems from lib/schema.js:1113 where |
Thanks for the repro script and sorry for the trouble, the fix will be in 5.7.6 👍 |
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
The text was updated successfully, but these errors were encountered: