Stream stuck when used with mongodb and node10
See original GitHub issueHello, I really like Highland and I would like to continue to use it but it starts to be a problem with newest version of node.
The following example works just fine with node 8/9 but stays stuck when using node 10+
const MongoClient = require('mongodb').MongoClient;
const hl = require('highland');
const MONGO_URL = 'mongodb://localhost:27017/';
const DB_NAME = 'someDb';
const COLLECTION = 'someCollection';
const run = async () => {
const mongo = new MongoClient(url);
await mongo.connect();
const cursor = mongo.db(DB_NAME)
.collection(COLLECTION)
.find()
.stream();
return new Promise((resolve, reject) => {
return hl(cursor)
.batch(5)
.flatten()
.map(x => console.log(x && x._id))
.stopOnError(reject)
.done(resolve);
});
};
run()
.catch(console.log)
.then(() => process.exit())
If you replace the mongoDb stream by a simple stream like this one it works just fine:
class Counter extends Readable {
constructor(opt) {
super({ ...opt, objectMode: true });
this._max = 1000000;
this._index = 1;
}
_read() {
const i = this._index++;
if (i > this._max)
this.push(null);
else {
this.push({ count: i });
}
}
}
Thing is I had a look at the stream implementation inside mongoDB lib and they used the node stream implementation, I have seen nothing weird about it. And something else is a little bit strange, if you remove the flatten inside the hl chain, the stream will not be stucked anymore(even with node10).
Anyway I have no clue what the problem is so if anyone has an idea please share it.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
Change events stream stops working when a node fails in ...
I am having a problem with mongodb (version 4.2), ... Starting MongoDB 3.6 change streams are using read concern “majority” by default which ......
Read more >Change stream hanging while fetching update events - M220J
So i was working on ChangeStreams test case in the mongo mflix , incase ... UPDATE_LOOKUP) to db.watch(oddFilter) then the test case hangs...
Read more >Kafka connector stuck with MongoDB Change Stream error
Hello Team, We encountered following error when were doing Kafka MongoDB Source Connector: [2021-03-02 07:15:33282] INFO An exception ...
Read more >Read change streams with multiple threads - MongoDB
You can have multiple thread receiving different change stream message if the query used to set up the stream is different.
Read more >Change Streams & Triggers with Node.js Tutorial - MongoDB
Discover how to react to changes in your MongoDB database using change streams implemented in Node.js and Atlas triggers.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This fix has been released as 3.0.0-beta.8 and 2.13.1.
Hello,
I can confirm the changes also fix my use case 😃