-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
can't reproduceMongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.performance
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the performance issue has not already been reported
Last performant version
1.2.5
Slowed down in version
1.x.x
Node.js version
2.0.0
🦥 Performance issue
After upgrading to version 2.x.x, the validation step for schemas has become significantly slower.
A test that previously ran instantly now takes approximately 200–300ms longer.
This slowdown occurs consistently across multiple test runs.
Steps to Reproduce
- Install version 2.x.x of the package.
- Create a simple schema that includes a Date field.
- Run the following test code:
const mongoose = require('mongoose');
const TestSchema = new mongoose.Schema({
createdAt: Date
});
const Test = mongoose.model('Test', TestSchema);
// Trigger cast error by passing a boolean for a Date field
console.time('validate');
const result = new Test({ createdAt: true }).validateSync();
console.timeEnd('validate');
### Expected Behavior
The validation should run with the same performance as in version 1.x.x.
Calling `validateSync()` should be fast and should not introduce any noticeable delay.
There should be no slowdown when validating a schema with a Date field, even when an invalid value (such as a boolean) is provided.Metadata
Metadata
Assignees
Labels
can't reproduceMongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.performance