Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent double callback in getBlocks. #20

Merged
merged 1 commit into from
Jun 15, 2016

Conversation

hackergrrl
Copy link
Contributor

I found this after doing some digging in ipfs/js-ipfs#318.

It looks like we can call finish both here and here.

As far as I've been able to tell, a getBlock request will reach datastore.get and block there because the put is still in progress. At this point the notification handler here will be set up. Once the block finishes being put, it both a) fires the notification, and also b) makes that earlier datastore.get return successfully, making finish get called twice.

I'm not very familiar with this module, so let me know if there's a more complete fix here than simply preventing the cb from running twice! ❤️

@@ -190,6 +190,7 @@ module.exports = class Bitwap {
})
}

var finished = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use let

@dignifiedquire
Copy link
Member

Thanks for the catch, one small nit other than that looks good

@hackergrrl
Copy link
Contributor Author

hackergrrl commented Jun 12, 2016 via email

@dignifiedquire
Copy link
Member

Thanks, lgtm could you please squash the commits?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants