mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-06 08:27:10 +00:00
refactor(session): skip logging for client context cancellations
We use the context from the inbound http.Request, which means that this error generally occurs due to the user agent disconnecting mid-request. Skip logging these errors as they're not really actionable.
This commit is contained in:
@@ -113,12 +113,16 @@ func (in *manager) GetOrRefresh(r *http.Request) (*Session, error) {
|
||||
}
|
||||
|
||||
refreshed, err := in.Refresh(r, sess)
|
||||
if err == nil {
|
||||
return refreshed, nil
|
||||
}
|
||||
|
||||
if errors.Is(err, ErrInvalidExternal) || errors.Is(err, ErrInvalid) {
|
||||
return nil, err
|
||||
} else if err != nil {
|
||||
}
|
||||
|
||||
if !errors.Is(err, context.Canceled) {
|
||||
mw.LogEntryFrom(r).Warnf("session: could not refresh tokens; falling back to existing tokens: %+v", err)
|
||||
} else {
|
||||
sess = refreshed
|
||||
}
|
||||
|
||||
return sess, nil
|
||||
@@ -166,7 +170,7 @@ func (in *manager) Refresh(r *http.Request, sess *Session) (*Session, error) {
|
||||
}
|
||||
defer func(lock Lock, ctx context.Context) {
|
||||
err := lock.Release(ctx)
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, context.Canceled) {
|
||||
logger.Warnf("session: releasing lock: %+v", err)
|
||||
}
|
||||
}(lock, ctx)
|
||||
|
||||
Reference in New Issue
Block a user