algorand / algorand/js-algorand-sdk

`waitForConfirmation` may throw errors unrelated to a transaction's success/failure

未关闭
#615 0 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看
community interest Team Scytale
主要语言
TypeScript
星标
297
派生
214
平均合并
1 小时 3 分钟
30 天内合并 PR
3

描述

## Problem

The `waitForConfirmation` function is responsible for returning a promise with the following properties:
* Successfully resolves when the identified transaction has been confirmed in a block
* Errors if `waitRounds` rounds have passed without the transaction being confirmed in a block
* Errors if the transaction was rejected from the pending pool

However, due to the nature of its implementation, there is another situation in which the function may error:
* Errors if a network issue happens or if an invalid algod status is returned

In addition to this unplanned error case, the design of this function has a problem: the caller has no way of determining why the function fails, except by parsing the returned error message string, which we consider to be error-prone and less than ideal.

This is a problem because the function may return an error due to timeout or network issues, but the transaction in question may still get confirmed in a block. This misleading messaging can be very problematic for the calling code.

## Solution

We believe the optimal solution is to improve the caller's ability to determine why the `waitForConfirmation` function fails.

If the caller is able to know with certainty whether a failure is because the transaction was rejected or because of a different reason, the caller will be better equipped to take the appropriate follow-up actions. Appropriate actions may be attempting to further wait for confirmation, or determining that it's necessary to submit a variation of the original transaction again.

Specifically, this solution would create new error types which would allow the caller to more easily differentiate between them to determine the type of error that occurred.

If we find success with this solution, the goal is to replicate this work across the 3 other SDKs we support.

---

Thanks to @AlgoDoggo who first made us aware of this problem in #601.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。