Skip to content

Conversation

@vkarpov15
Copy link
Collaborator

Before:

$ time node gh-7895.js real	0m10.777s user	0m11.311s sys	0m0.354s 

After:

$ time node gh-7895.js real	0m7.058s user	0m7.194s sys	0m0.048s 

Should be fine to release in 5.6.8, but I want to see if we can make this a little bit faster, because this is still slightly slower than Mongoose 4.13

@vkarpov15
Copy link
Collaborator Author

It looks like I managed to fix the tests by removing event emitter registration in the doc array constructor - it isn't strictly necessary because we can just set isNew normally. However, this means I'd like to defer this change to 5.7.0. It shouldn't be backwards breaking, but it feels a little too risky for a patch release.

@brettkiefer
Copy link

brettkiefer commented Jul 31, 2019

This looks great! I found something kind of funny running our test suite against it that I thought I'd alert you to. I'm not sure if you'd consider it to be a bug in util.inspect, in this change, or neither.

If you run this script on 336e995 (with node 10 and 12, at least), you'll get infinite recursion in inspect's formatValue and ultimately RangeError: Maximum call stack size exceeded, whereas with e.g. 5.6.5, it would inspect the subdoc array as expected.

'use strict'; const mongoose = require('.'); const { inspect } = require('util'); const SubdocSchema = mongoose.Schema({ a: String, b: String, c: String, d: String, e: String }); const Schema = mongoose.Schema({ name: String, subdocs: { type: [SubdocSchema] } }); const Model = mongoose.model('Test', Schema); const data = { _id: new mongoose.Types.ObjectId(), name: 'test', subdocs: [{a: 'a'}] }; const model = new Model(); model.init(data); console.log(inspect(model.subdocs)); 

That may be something you'd expect consumers to work around, but I thought it was worth calling out.

@vkarpov15 vkarpov15 added this to the 5.7 milestone Aug 5, 2019
@vkarpov15
Copy link
Collaborator Author

Thanks @brettkiefer , I will look into this before merging

@vkarpov15 vkarpov15 changed the base branch from master to 5.7 August 26, 2019 12:38
@vkarpov15 vkarpov15 merged commit b4d8e8f into 5.7 Aug 26, 2019
vkarpov15 added a commit that referenced this pull request Aug 26, 2019
vkarpov15 added a commit that referenced this pull request Aug 26, 2019
@brettkiefer
Copy link

To close the loop, f96a041 fixed the issue in our test suite that initially brought the infinite recursion issue up. Thank you!

@vkarpov15 vkarpov15 deleted the gh7895 branch September 4, 2019 14:50
@Fonger Fonger mentioned this pull request Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants