Interview frequency: …
Short answer
Mongoose provides an advanced ODM layer; Command Buffering lets model queries be issued before the initial connection is ready and queues them until the connection succeeds.
Explanation
If the connection is not ready, Mongoose temporarily stores model queries in an internal queue (Buffer). Although this simplifies code during server startup, it can hide database connection failures and leave requests hanging until the buffer timeout expires (10 seconds by default).
Code example
await mongoose.connect(process.env.MONGO_URI!, {
serverSelectionTimeoutMS: 5000
});Common mistakes
- Not disabling command buffering in Serverless environments, which can leave cloud functions hanging.