aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.39k stars 2.11k forks source link

Amplify REST requests should not automatically retry on serverside errors #13093

Open severi opened 3 months ago

severi commented 3 months ago

Before opening, please confirm:

JavaScript Framework

Not applicable

Amplify APIs

REST API

Amplify Version

v6

Amplify Categories

api

Backend

None

Environment information

``` # Put output below this line not applicable ```

Describe the bug

Amplify should never automatically try to retry API requests if they fail on serverside errors (500, 502, 503, 504)

https://github.com/aws-amplify/amplify-js/blob/main/packages/core/src/clients/middleware/retry/defaultRetryDecider.ts#L26C4-L26C21

This behaviour is just plain wrong and should not exists OR at the very least should be possible to be disabled

Expected behavior

Api request fails once and is not retryed

Reproduction steps

server responds with error code 500, amplify post request automatically retries 2 times after the failed attempt

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

chrisbonifacio commented 3 months ago

Hi @severi Thank you for raising this issue. We were able to reproduce the issue.

image

We'll bring this to the team's attention and see how we can address it, whether it be through changing the behavior or exposing a way to disable this behavior.

Philip-Bro commented 2 months ago

any updates for this

EricDAllen commented 2 months ago

I'm picturing a badly-coded server that is starting to fail when it gets overloaded. Arbitrarily tripling the number of requests sent to it really doesn't seem helpful.

metuuu commented 2 months ago

I am using TanStack Query and would like to use its retrying system rather than amplify's. Is it even possible currently to disable amplify api retrying completely?

chris-xylem commented 1 week ago

Checking to see if there has been an update on this bug?