mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 10:02:24 -05:00
[performance] Don't retry/backoff invalid http requests that will never succeed (#609)
* add httpguts (ew) * add ValidateRequest err wrapping logic * don't retry on unrecoverable errors * i am very clever
This commit is contained in:
parent
0f01f72db0
commit
1cdc163276
8 changed files with 487 additions and 4 deletions
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/activity/pub"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/httpclient"
|
||||
)
|
||||
|
||||
// Transport wraps the pub.Transport interface with some additional functionality for fetching remote media.
|
||||
|
|
@ -123,8 +124,14 @@ func (t *transport) do(r *http.Request, signer func(*http.Request) error, retryO
|
|||
|
||||
// Generate error from status code for logging
|
||||
err = errors.New(`http response "` + rsp.Status + `"`)
|
||||
} else if errorsv2.Is(err, context.DeadlineExceeded, context.Canceled) {
|
||||
// Return early if context has cancelled
|
||||
} else if errorsv2.Is(err,
|
||||
context.DeadlineExceeded,
|
||||
context.Canceled,
|
||||
httpclient.ErrInvalidRequest,
|
||||
httpclient.ErrBodyTooLarge,
|
||||
httpclient.ErrReservedAddr,
|
||||
) {
|
||||
// Return on non-retryable errors
|
||||
return nil, err
|
||||
} else if strings.Contains(err.Error(), "stopped after 10 redirects") {
|
||||
// Don't bother if net/http returned after too many redirects
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue