[ck] Proper promise treatment to avoid UnhandledPromises #1219
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When a sendTransaction is reject, we need to make sure every rejects promise is handled.
Usually, a user would do:
Others, may directly call
res.waitReceipt()
and don't callres.getHash()
.The problem is when
sendTransaction()
fails, and thus both promises (hash & receipt) are rejected. The promises are created when the txResult is created, not when the methods are called. So we need to make sure wecatch
those errors.This PR address that, by adding
catch
logic in both methods.Tested
Manually, when factoring e2e transfer tests