Hello.
I encounter the issue that sometimes (not always) mongodb stream gets paused after 1 document being processed.
Node.js 22.13.1
Node.js mongodb package 4.17.2
I do the following:
db.collection('my-collection')
.find({
date: {
$gte: start,
$lte: end
}
})
.stream({
transform: transformDecorator()
})
.on('pause', () => {
req.timeoutDebug.streamPausedAt = new Date();
})
.on('resume', () => {
req.timeoutDebug.streamResumedAt = new Date();
})
.pipe(res);
transformDecorator contains only syncronious code.
The code works most of the time (several times a minute), but once in 1-2 hours it gets paused and never resumed.
On stream timeout I output the timeoutDebug data:
{
"totalTransforms":1,
"startedAt":"2025-02-20T15:01:59.186Z",
"firstTransformStartedAt":"2025-02-20T15:02:11.497Z",
"streamResumedAt":"2025-02-20T15:02:15.134Z",
"streamPausedAt":"2025-02-20T15:02:15.141Z"
}
So here I see that stream was paused after being resumed the last time.
I struggle to understand the source of the pause events. This is critical as it affects our production system.
Any help is appreciated.
Thank you