Skip to content

Commit

Permalink
fix(share/shrex): return aggregated error if context Deadline reached (
Browse files Browse the repository at this point in the history
…#2243)

## Overview

Errors were lost on context deadline
  • Loading branch information
walldiss committed May 25, 2023
1 parent ec41fcb commit 5fa0244
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions share/getters/shrex.go
Expand Up @@ -130,19 +130,18 @@ func (sg *ShrexGetter) GetEDS(ctx context.Context, root *share.Root) (*rsmt2d.Ex
for {
if ctx.Err() != nil {
sg.metrics.recordEDSAttempt(ctx, attempt, false)
return nil, ctx.Err()
return nil, errors.Join(err, ctx.Err())
}
attempt++
start := time.Now()
peer, setStatus, getErr := sg.peerManager.Peer(ctx, root.Hash())
if getErr != nil {
err = errors.Join(err, getErr)
log.Debugw("eds: couldn't find peer",
"hash", root.String(),
"err", getErr,
"finished (s)", time.Since(start))
sg.metrics.recordEDSAttempt(ctx, attempt, false)
return nil, fmt.Errorf("getter/shrex: %w", err)
return nil, errors.Join(err, getErr)
}

reqStart := time.Now()
Expand Down Expand Up @@ -197,19 +196,18 @@ func (sg *ShrexGetter) GetSharesByNamespace(
for {
if ctx.Err() != nil {
sg.metrics.recordNDAttempt(ctx, attempt, false)
return nil, ctx.Err()
return nil, errors.Join(err, ctx.Err())
}
attempt++
start := time.Now()
peer, setStatus, getErr := sg.peerManager.Peer(ctx, root.Hash())
if getErr != nil {
err = errors.Join(err, getErr)
log.Debugw("nd: couldn't find peer",
"hash", root.String(),
"err", getErr,
"finished (s)", time.Since(start))
sg.metrics.recordNDAttempt(ctx, attempt, false)
return nil, fmt.Errorf("getter/shrex: %w", err)
return nil, errors.Join(err, getErr)
}

reqStart := time.Now()
Expand Down

0 comments on commit 5fa0244

Please sign in to comment.