mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-22 03:37:43 +00:00
report timeout errors separately
This commit is contained in:
parent
7f8d0c3375
commit
42a9fb415e
3 changed files with 22 additions and 14 deletions
|
@ -107,6 +107,9 @@ func (rac *AuthenticatedClient) request(r *Request, rh ResponseHandler, empty in
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rac.statsd.Incr("reddit.api.errors", r.tags, 0.1)
|
rac.statsd.Incr("reddit.api.errors", r.tags, 0.1)
|
||||||
|
if strings.Contains(err.Error(), "http2: timeout awaiting response headers") {
|
||||||
|
return nil, ErrTimeout
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
|
@ -16,4 +16,6 @@ func (se ServerError) Error() string {
|
||||||
var (
|
var (
|
||||||
// ErrOauthRevoked .
|
// ErrOauthRevoked .
|
||||||
ErrOauthRevoked = errors.New("oauth revoked")
|
ErrOauthRevoked = errors.New("oauth revoked")
|
||||||
|
// ErrTimeout .
|
||||||
|
ErrTimeout = errors.New("timeout")
|
||||||
)
|
)
|
||||||
|
|
|
@ -243,25 +243,28 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
|
||||||
msgs, err := rac.MessageInbox(opts...)
|
msgs, err := rac.MessageInbox(opts...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != reddit.ErrOauthRevoked {
|
switch err {
|
||||||
|
case reddit.ErrTimeout: // Don't log timeouts
|
||||||
|
break
|
||||||
|
case reddit.ErrOauthRevoked:
|
||||||
|
err = nc.deleteAccount(ctx, account)
|
||||||
|
if err != nil {
|
||||||
|
nc.logger.WithFields(logrus.Fields{
|
||||||
|
"account#username": account.NormalizedUsername(),
|
||||||
|
"err": err,
|
||||||
|
}).Error("failed to remove revoked account")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
nc.logger.WithFields(logrus.Fields{
|
||||||
|
"account#username": account.NormalizedUsername(),
|
||||||
|
}).Info("removed revoked account")
|
||||||
|
break
|
||||||
|
default:
|
||||||
nc.logger.WithFields(logrus.Fields{
|
nc.logger.WithFields(logrus.Fields{
|
||||||
"account#username": account.NormalizedUsername(),
|
"account#username": account.NormalizedUsername(),
|
||||||
"err": err,
|
"err": err,
|
||||||
}).Error("failed to fetch message inbox")
|
}).Error("failed to fetch message inbox")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = nc.deleteAccount(ctx, account)
|
|
||||||
if err != nil {
|
|
||||||
nc.logger.WithFields(logrus.Fields{
|
|
||||||
"account#username": account.NormalizedUsername(),
|
|
||||||
"err": err,
|
|
||||||
}).Error("failed to remove revoked account")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
nc.logger.WithFields(logrus.Fields{
|
|
||||||
"account#username": account.NormalizedUsername(),
|
|
||||||
}).Info("removed revoked account")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue