Automattic/mongoose · error · Error
Can not use `limit` and `perDocumentLimit` at the same time.
Error message
Can not use `limit` and `perDocumentLimit` at the same time. Path: `${obj.path}`. What it means
Error "Can not use `limit` and `perDocumentLimit` at the same time. Path: `${obj.path}`." thrown in Automattic/mongoose.
Source
Thrown at lib/options/populateOptions.js:21
const clone = require('../helpers/clone');
class PopulateOptions {
constructor(obj) {
this._docs = {};
this._childDocs = [];
if (obj == null) {
return;
}
obj = clone(obj);
Object.assign(this, obj);
if (typeof obj.subPopulate === 'object') {
this.populate = obj.subPopulate;
}
if (obj.perDocumentLimit != null && obj.limit != null) {
throw new Error('Can not use `limit` and `perDocumentLimit` at the same time. Path: `' + obj.path + '`.');
}
}
}
/**
* The connection used to look up models by name. If not specified, Mongoose
* will default to using the connection associated with the model in
* `PopulateOptions#model`.
*
* @memberOf PopulateOptions
* @property {Connection} connection
* @api public
*/
module.exports = PopulateOptions;
View on GitHub (pinned to 49cdab0136)
When it happens
Trigger: Thrown at lib/options/populateOptions.js:21 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Automattic/mongoose@49cdab0136 (2026-08-21).
Data as JSON: /api/errors/6cf2412b4745afb7.
Report an issue: GitHub.