Closed ryanschneider closed 4 years ago
question/FYI: do we know if t.ctx.Err()
!= nil? cause errors.Wrap(nil, string) returns nil
question/FYI: do we know if
t.ctx.Err()
!= nil? cause errors.Wrap(nil, string) returns nil
Ya, it returns nil. This is so you can do things like: return errors.Wrap(someOperation(), "operation failed")
I agree with the discussion in your link that MaybeWrap
would've been a better choice for this behavior but it's how pkg/errors
has always behaved as far as I know.
I just ran into a corner case during a network issue when debugging locally that I'm pretty sure I traced back to this issue.
Normally
loopingTransport.ctx
and thectx
passed into.Request
are the same, or at least in the same tree, but they don't have to be, so it's definitely a bug that we'd do<-t.ctx.Done
but returnctx.Err()
. This led to the scenario where.Request()
returned(nil, nil)
which it shouldn't.