Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Mongoose version
7.x.x
Node.js version
18.x
MongoDB server version
5
Typescript version (if applicable)
5
Description
Issue
Logging with custom log function missing last argument due to incorrect slicing index.
Potential fix
Clone array with args.slice(0, args.length)
Risk
- May require existing code to add redact action on large objects such as
session
which happen to be in last argument
Steps to Reproduce
import { connect } from 'mongoose';
import * as util from 'util';
(async () => {
const MONGO_CONNECTION_STRING = 'mongodb://localhost:27017/db?&directConnection=true';
const mongoose = await connect(MONGO_CONNECTION_STRING);
mongoose.set('debug', (collectionName, methodName, ...methodArgs) => {
console.log(`${collectionName}.${methodName}(${util.inspect(methodArgs).slice(2, -2)})`);
});
const collection = mongoose.connection.collection('Test');
await collection.findOne({ key: 'value' });
await mongoose.connection.close();
})();
Expected Behavior
Expect: print Test.findOne({ key: 'value' })
Actual: print Test.findOne()