Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle API failure #731

Merged
merged 2 commits into from
Jun 25, 2019
Merged

Handle API failure #731

merged 2 commits into from
Jun 25, 2019

Conversation

ohmoses
Copy link
Contributor

@ohmoses ohmoses commented Jun 24, 2019

Closes #713

To try out the fix:

  • Start Publish and API, open Publish, kill API, navigate to any collection list or document; you should see an error message.
  • Restart API and click "Try again" or navigate elsewhere and back; the collection/document loads.
  • Kill API and refresh Publish; you get the error message instead of the sign in screen.

Notes/explanations:

  • I tried to reuse mechanisms that exist or have existed in the code at some point, e.g. window.__api__ window.__error__ and the api reducer to convey the API error from the backend to the frontend.
  • When you get a backend error (backend failed to connect in the first place), the "Try again" button reloads the page so that the backend gets a chance to load the data from API.
  • On frontend error (API failure while navigating to a collection/document) the "Try again" button didn't trigger refetch of data—it navigates to the same page it's already on, so the only thing that changes is the React Router location hash key. I refetch the data if the key changes. Edit: As per discussion with @eduardoboucas, the "Try again" button now flags the document or document list as dirty, forcing refetch.
  • ErrorView in App.js has to be wrapped in Router to be able to use the Link component.
  • I fixed an error where trying to delete documents while the API was down triggered a notification falsely informing of successful deletion.

@ohmoses ohmoses requested a review from eduardoboucas June 24, 2019 06:30
@dadi dadi deleted a comment from eduardoboucas Jun 24, 2019
@dadi dadi deleted a comment from eduardoboucas Jun 24, 2019
@ohmoses ohmoses force-pushed the fix/handle-api-fails branch from 0124e83 to d21b2af Compare June 25, 2019 08:49
Copy link
Contributor

@eduardoboucas eduardoboucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@ohmoses ohmoses merged commit 069fad1 into develop Jun 25, 2019
@ohmoses ohmoses deleted the fix/handle-api-fails branch June 25, 2019 10:28
@mingard
Copy link
Contributor

mingard commented Jun 25, 2019

👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offline API causes white screen when a session is present
3 participants