Prerequisites
Last performant version
Slowed down in version
8.1.1
Node.js version
16.20.2
🦥 Performance issue
When you use streaming API of QueryCursor and you need to destory stream for some reason (e.g. the upstream was destoryed too) it won't close the cursor and the cursor and session will hang in memory (activeSessions)
Steps to Reproduce
const mongoose = require('mongoose');
const Model = require('./Model');
const stream = Model.find().cursor();
console.log(stream.cursor.closed);
stream.destroy();
console.log(stream.destroyed);
console.log(stream.cursor.closed);
console.log([...mongoose.connection.client.s.activeSessions.values()])
Expected Behavior
It looks to me that the correct behavior should be — to automatically call cursor.close() when the stream is destroyed
Prerequisites
Last performant version
Slowed down in version
8.1.1
Node.js version
16.20.2
🦥 Performance issue
When you use streaming API of QueryCursor and you need to
destorystream for some reason (e.g. the upstream was destoryed too) it won't close the cursor and the cursor and session will hang in memory (activeSessions)Steps to Reproduce
Expected Behavior
It looks to me that the correct behavior should be — to automatically call
cursor.close()when the stream is destroyed