Automattic/mongoose · error · MongooseError
Mongoose.prototype.disconnect() no longer accepts a callback
Error message
Mongoose.prototype.disconnect() no longer accepts a callback
What it means
Error "Mongoose.prototype.disconnect() no longer accepts a callback" thrown in Automattic/mongoose.
Source
Thrown at lib/mongoose.js:487
const _mongoose = this instanceof Mongoose ? this : mongoose;
if (_mongoose.connection == null) {
_createDefaultConnection(_mongoose);
}
const conn = _mongoose.connection;
return conn.openUri(uri, options).then(() => _mongoose);
};
/**
* Runs `.close()` on all connections in parallel.
*
* @return {Promise} resolves when all connections are closed, or rejects with the first error that occurred.
* @api public
*/
Mongoose.prototype.disconnect = async function disconnect() {
if (arguments.length >= 1 && typeof arguments[0] === 'function') {
throw new MongooseError('Mongoose.prototype.disconnect() no longer accepts a callback');
}
const _mongoose = this instanceof Mongoose ? this : mongoose;
const remaining = _mongoose.connections.length;
if (remaining <= 0) {
return;
}
await Promise.all(_mongoose.connections.map(conn => conn.close()));
};
/**
* _Requires MongoDB >= 3.6.0._ Starts a [MongoDB session](https://www.mongodb.com/docs/manual/release-notes/3.6/#client-sessions)
* for benefits like causal consistency, [retryable writes](https://www.mongodb.com/docs/manual/core/retryable-writes/),
* and [transactions](https://thecodebarbarian.com/a-node-js-perspective-on-mongodb-4-transactions.html).
*
* Calling `mongoose.startSession()` is equivalent to calling `mongoose.connection.startSession()`.
* Sessions are scoped to a connection, so calling `mongoose.startSession()`View on GitHub (pinned to 49cdab0136)
When it happens
Trigger: Thrown at lib/mongoose.js:487 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/6bd5e84d1c435d12.
Report an issue: GitHub.