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

Serve /error paths from back-end, and remove those routes from front-end #2300

Open
louh opened this issue Mar 17, 2021 · 0 comments
Open

Serve /error paths from back-end, and remove those routes from front-end #2300

louh opened this issue Mar 17, 2021 · 0 comments

Comments

@louh
Copy link
Member

louh commented Mar 17, 2021

As a single-page app, Streetmix has been designed in such a way that the front-end holds a lot of responsibility for things that have traditionally been handled by the back-end: routing, for example. In particular, we have a particular series of routes which are intended to halt the application because an error has occurred, for instance: https://streetmix.net/error/authentication-api-problem

This issue is meant to focus on a class of errors that are reached by routing to a URL that uses the /error/ path. It is not meant to address generic application-wide errors, such as a 404 error (although it is, of course, related. See prior art section, below).

Current code references

The problem

The current arrangement requires loading the entire application JS bundle in order to display the error message. Load times are increased. This can be a poor user experience, and also demands higher resources from the server if any additional requests are made before the application is halted.

The proposal

Because these errors are served at a route, the back-end can serve static pages for these errors, rather than the entire application.

Known gotchas (thorny problems to solve)

  • Not all errors are good candidates for back-end static-page implementation, especially if they also contain UI interactions that depend on the front end code. Errors of this type may need to be reworked, or they may need to remain in the front-end code. (See, for example, errors that call the sign-in dialog, or include a user avatar.)
  • Static page errors need to be localized. When error messages occur on the front-end, they could be localized using the react-intl library and the translation strings, which are already loaded as part of the application bundle. When served as static pages, localization needs to be done in a different way. Some proposals include:
    • Do nothing. Let the user agent (browsers) determine what to do with English content.
    • Serve static, localized versions of the error page by detecting the user agent language and routing to a URL with a locale fragment, e.g. https://streetmix.net/error/de/authentication-api-problem
    • Serve dynamic pages with JavaScript that detects the user agent language or the user preference stored in localStorage, and updating the text inline.

Prior art

  • Back end should be serving a 404 (although it's possible this is not currently working as intended). This issue is not meant to fix the prior issue, only to note that we have partially addressed a similar problem in the past and this can be used as a reference.

Prior issues

These issues may be addressed in the scope of this issue.

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

No branches or pull requests

2 participants