Skip to content

Commit

Permalink
Makes context timeout error behavior consistent.
Browse files Browse the repository at this point in the history
If user provides context object and context timeout,
always return the timeout error from context.
  • Loading branch information
wdhongtw committed Jul 2, 2022
1 parent 428daee commit 74018d1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js.go
Expand Up @@ -2574,9 +2574,9 @@ func (sub *Subscription) Fetch(batch int, opts ...PullOpt) ([]*Msg, error) {
// Check if context not done already before making the request.
select {
case <-ctx.Done():
if ctx.Err() == context.Canceled {
if o.ctx != nil { // Timeout or Cancel triggered by context object option
err = ctx.Err()
} else {
} else { // Timeout triggered by timeout option
err = ErrTimeout
}
default:
Expand Down

0 comments on commit 74018d1

Please sign in to comment.