magento / pwa-studio

🛠Development tools to build, optimize and deploy Progressive Web Applications for Magento 2.
https://developer.adobe.com/commerce/pwa-studio/
Open Software License 3.0
1.07k stars 684 forks source link

[feature]: Don't pile onto the backend #2522

Closed fooman closed 4 years ago

fooman commented 4 years ago

Is your feature request related to a problem? Please describe. If the backend is experiencing issues (ie responding with a server 500 error) PWA Studio aggressively keeps trying to reconnect. image image

Describe the solution you'd like Ideally some retry logic is added to the reconnect to back off after a certain number of fails. Also the user frontend would benefit from only 1 toast message per issue rather than hundreds.

Please let us know what packages this feature is in regards to:

m2-assistant[bot] commented 4 years ago

Hi @fooman. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


Jordaneisenburger commented 4 years ago

I believe it's default is to retry every failed call 5 times, that's why the errors start to pile up. What we figured is that if we get a 503 we go show a maintenance page. Not sure if we can do the same for 500's

sirugh commented 4 years ago

@Jordaneisenburger is correct, the retry link should limit it to some number like 5. If you're seeing an excessive amount of calls there may be some buggy logic in the code that is attempting a retry beyond what is handled by Apollo. Can you provide steps to repro the errors? Was it any gql call that resulted in 500 or was it a specific call?

awilcoxa commented 4 years ago

Created PWA-732 in Jira backlog for further grooming

fooman commented 4 years ago

Any graphql was returning a 500 error. Something like this reproduces it for me.

yarn build edit packages/venia-concept/dist/upward.yml

veniaProxy:
  inline:
    status: 500
    headers:
      resolver: inline
      inline:
        content-type: text/html
    body:
      headers:
        resolver: inline
        inline: NOT OK

cd packages/venia-concept yarn start

Open site.

fooman commented 4 years ago

There is also this message client.d7d157a7dfd7446e50e4.js:1027 Unhandled ApolloError30W Error: Network error: Response not successful: Received status code 500

sirugh commented 4 years ago

@fooman I'm looking into this now - I'm able to replicate without modifying files - just clear cache and block <your-domain>/graphl network requests in chrome's dev tools (or via a proxy mechanism).

At a glance it looks like the logic in our actions were not written to handle unrecoverable errors. They all assume that an error is retry-able. In this case, if there is no cart id, we ask /graphql for one. If it errors, we log the error (as you can see with the toast) but then we immediately retry the action because we assume it was successful.

sirugh commented 4 years ago

https://github.com/magento/pwa-studio/pull/2574