check for DeadlineExceeded

This commit is contained in:
aodhgan 2025-10-13 12:57:23 -07:00
parent 1d662b50a6
commit 3ab8ec880b

View file

@ -1694,14 +1694,19 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
for { for {
select { select {
case <-receiptCtx.Done(): case <-receiptCtx.Done():
// Upstream cancellation -> bubble it; otherwise emit the timeout error // If server-side wait window elapsed, return the structured timeout.
if err := ctx.Err(); err != nil { if errors.Is(receiptCtx.Err(), context.DeadlineExceeded) {
return nil, err
}
return nil, &txSyncTimeoutError{ return nil, &txSyncTimeoutError{
msg: fmt.Sprintf("The transaction was added to the transaction pool but wasn't processed in %v.", timeout), msg: fmt.Sprintf("The transaction was added to the transaction pool but wasn't processed in %v.", timeout),
hash: hash, hash: hash,
} }
}
// Otherwise, bubble the caller's context error (canceled or deadline).
if err := ctx.Err(); err != nil {
return nil, err
}
// Fallback: return the derived context's error.
return nil, receiptCtx.Err()
case err, ok := <-subErrCh: case err, ok := <-subErrCh:
if !ok || err == nil { if !ok || err == nil {