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

[Docs]WaitForTransaction()Function poll timeout #843

Open
paterleng opened this issue Mar 6, 2025 · 2 comments
Open

[Docs]WaitForTransaction()Function poll timeout #843

paterleng opened this issue Mar 6, 2025 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@paterleng
Copy link

Aptos Documentation Issue

Location

code:

func (rc NodeClient) PollForTransaction(hash string, options ...any) (api.UserTransaction, error) {
period, timeout, err := getTransactionPollOptions(100
time.Millisecond, 10
time.Second, options...)
if err != nil {
return nil, err
}
start := time.Now()
deadline := start.Add(timeout)
for {
if time.Now().After(deadline) {
return nil, errors.New("PollForTransaction timeout")
}
time.Sleep(period)
txn, err := rc.TransactionByHash(hash)
if err == nil {
if txn.Type == api.TransactionVariantPending {
// not done yet!
} else if txn.Type == api.TransactionVariantUser {
// done!
slog.Debug("txn done", "hash", hash)
return txn.UserTransaction()
}
}
}
}

Description

在这里面去轮询hash获取信息时,如果交易很慢,就会轮询失败,导致状态判断错误,

@paterleng paterleng added the documentation Improvements or additions to documentation label Mar 6, 2025
@jmintuitive
Copy link
Collaborator

jmintuitive commented Mar 6, 2025

Does increasing the timeout fix your problem? (Also, if this is in the docs, can you link to the page which you think should change?)

Translated with AI / 由AI翻译: 增加超时时间能解决你的问题吗?另外,如果这在文档中有提到,你能链接到你认为需要修改的页面吗?

@paterleng
Copy link
Author

paterleng commented Mar 6, 2025

可以解决我的问题,我这提的问题是在GoSDK里面,有个地方关于超时时间设置的不是很合理

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

No branches or pull requests

2 participants