Add listener to events.on("error") - #1221
Conversation
|
Adding for reference; this node issue is documented here. |
|
I don't really understand the fix. The question is, do I only need to add error event listener somewhere, or will that be added directly in OrbitDB, in my app, or I am getting something completely wrong. |
|
@silkroadnomad This is due to the behaviour of Node.js documented here which throws an error when EventEmittor.emit("error") is called with no previously registered listeners. Until this PR is resolved, if you add a listener elsewhere in your app (to the db.events object), any errors will not result in a process exit. |
|
This is very good news Julien! Thanks so much for figuring that out. This issue led to db crashes, in my opinion, which made it inaccessible and causes a lot of headaches. I am wondering if an interrupted internet connection during an ongoing longer replication / bigger db sync now just leads to an incomplete sync or a sync that is rolled back again or still in a corrupted level db. Also. if I click a button to load a remote db, it would sync and if I click quickly to load other db's a view times, it would probably not finish the replication which then leads to "some sort of stream ended pushable errors" (but now without the app crash) In case an error occurs, however, it is necessary to close the db so nothing bad happens. I am still tapping a bit in the dark here. But it's good we are having all the same challenges. |
Node.js, by default, throws an error if an EventEmitter emits an "error" event and no other listener is configured. This causes OrbitDB to crash the main thread on Node.js whenever a libp2p error occurs during synchronisation.