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

[ck] Proper promise treatment to avoid UnhandledPromises #1219

Merged
merged 2 commits into from
Oct 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/contractkit/src/utils/tx-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,21 @@ export class TransactionResult {

/** Get (& wait for) transaction hash */
getHash() {
return this.hashFuture.wait()
return this.hashFuture.wait().catch((err) => {
// if hashFuture fails => receiptFuture also fails
// we wait for it here; so not UnhandlePromise error occurrs
this.receiptFuture.wait().catch(() => {
// ignore
})
throw err
})
}

/** Get (& wait for) transaction receipt */
waitReceipt() {
async waitReceipt() {
// Make sure `getHash()` promise is consumed
await this.getHash()

return this.receiptFuture.wait()
}
}