MetacoSA / NBitcoin

Comprehensive Bitcoin library for the .NET framework.
MIT License
1.86k stars 844 forks source link

Await send message operations to avoid unobserved exceptions #1089

Closed kiminuo closed 2 years ago

kiminuo commented 2 years ago

This PR attempts to fix some places where unobserved exceptions can be thrown. I would like to avoid introducing NBitcoin's design changes as much as possible. Note that this PR is not complete in the sense that it does not fix all SendMessageAsync calls (depends on feedback).

The PR is meant to be a preview really. Anyway, I believe that awaiting https://github.com/MetacoSA/NBitcoin/blob/cb6d64664b9f38d0442a4a4ad5edaed9e310bf40/NBitcoin/Protocol/Node.cs#L1085 would lead to significant decrease of unobserved exceptions in Wasabi.

WDYT? Concept ACK?

note: I believe https://github.com/zkSNACKs/WalletWasabi/issues/2554 is a result of not awaiting some an async method.

kiminuo commented 2 years ago

@NicolasDorier I have created a PR on Wasabi side https://github.com/zkSNACKs/WalletWasabi/pull/8081 to illustrate that this PR helps with unobserved exceptions.

MaxHillebrand commented 2 years ago

what's up with this?

kiminuo commented 2 years ago

It just shows that my fix works. This can be closed.

Nicolas is probably busy to work on that on NBitcoin's side so unfortunately no progress on this front.