Closed mistakia closed 6 years ago
Thank you for this PR @mistakia! :heart: Just one thing: I see you've done a lot of work to accommodate a new callback parameter, however we don't use return callbacks anywhere in the OrbitDB code base and aim to keep the code promise/await-based. Sorry this is not yet explicit, we're working on a standard to make it clear in the contribution guidelines! Care to amend your PR to remove the additional callback parameter?
At the time I was thinking this module might be depended on outside of OrbitDB π€π
5b067aa991cedc3250d79bf796810718804e0a51 LGTM (on orbitdb/orbit-db-pubsub#tests/fix-race
)
@mistakia would you want to pull that ^ branch into your branch and to this PR? You've done amazing job on finding the cause for the race condition (and they always take time to figure out) and did a lot of work to fix it (thank you!) and wouldn't want that work go waste.
Would love to have this as your contribution to the repo! π
I'm just glad to help - the nice thing about helping while not having commits merged is you can't get git-blame'd.
I've merged your branch here. Let me know if there's something else I can do here.
I'm just glad to help - the nice thing about helping while not having commits merged is you can't get git-blame'd.
We're extremely grateful for your help! You can git-blame it on me ;)
Before merging, let's make sure this code actually fixes the race condition. I believe we only need to run the tests again (several times as you did earlier) in https://github.com/orbitdb/orbit-db/pull/408, right?
Given the way I have the dep setup in package.json, I'm assuming CircleCI should pull in the latest commits?
I've run it a few times here. So far so good, except there was one failure for what seems to be a db not being able to be opened for a LOCK being held. I'll run it a few more times to make sure.
If you get fails in CI, perhaps try "Rebuild without cache" (to make sure Circle pulls in deps afresh).
Ready for another review.
I needed to use "Rebuild without cache" to pull in the latest commits. It failed due to an unhandled promise rejection because pseries expects an array of promise-returning functions (instead of the promises themselves).
I'm not very familiar with pseries so let me know if there's a more elegant solution. Otherwise, tests look good.
@mistakia LGTM! π Will run the tests a few more times just to make sure https://github.com/orbitdb/orbit-db/pull/408 passes with this PR.
If all good, I'll go ahead and merge, publish the new module and get ^ PR in orbitdb merged as well.
@mistakia thank you for digging into this, finding the reason for the bug and doing all the work to fix it. Appreciate it tremendously! β€οΈGreat job! π
Will do the dance of pushing this uptream and get it merged to orbitdb.
The updates you made to the README got lost during the process. I've added them back in here https://github.com/orbitdb/orbit-db-pubsub/commit/0889162776877b94422478726ec06ec7cb0130fd.
Update
IPFSPubsub.unsubscribe
andIPFSPubsub.disconnect
to be async as js-ipfs-api has updatedpubsub.unsubscribe
to be async.IPFSPubsub.unsubscribe
andIPFSPubsub.disconnect
can be used with callbacks or if no callback is provided it will return a promise so that you can useasync/await
.I also updated
IPFSPubsub.subscribe
to receive an optional callback - otherwise it will throw an error, like before.potentially related: orbitdb/orbit-db#370