diff --git a/docs/tokens/how-to-issue-an-asset.mdx b/docs/tokens/how-to-issue-an-asset.mdx index 5155c56a7..89786bb85 100644 --- a/docs/tokens/how-to-issue-an-asset.mdx +++ b/docs/tokens/how-to-issue-an-asset.mdx @@ -752,7 +752,9 @@ package main import ( "context" + "errors" "log" + "time" "github.com/stellar/go-stellar-sdk/clients/rpcclient" "github.com/stellar/go-stellar-sdk/keypair" @@ -777,7 +779,14 @@ func submit(ctx context.Context, client *rpcclient.Client, tx *txnbuild.Transact log.Fatalf("Submission failed: %s", sendResp.Status) } - finalResp, err := client.PollTransaction(ctx, sendResp.Hash) + // PollTransaction keeps polling until the context times out. + pollCtx, cancel := context.WithTimeout(ctx, 30*time.Second) + defer cancel() + finalResp, err := client.PollTransaction(pollCtx, sendResp.Hash) + if errors.Is(err, context.DeadlineExceeded) { + // Still NOT_FOUND: the status is unknown, not failed. + log.Fatalf("Status unknown, look up %s again later", sendResp.Hash) + } if err != nil { log.Fatal(err) }