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

Don't Redirect on Errors #570

Closed
kevincox opened this issue Feb 10, 2022 · 8 comments
Closed

Don't Redirect on Errors #570

kevincox opened this issue Feb 10, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@kevincox
Copy link

Is your proposal related to a problem?

Right now if the server returns an error (for example because the server is a bit loverloaded) you get redirected to a URL like https://lemmy.ml/404?err=FetchError:%20invalid%20json%20response%20body%20at%20http://lemmy:8536/api/v3/user?sort=New&saved_only=false&page=1&limit=20&auth=REDACTED&username=REDACTED%20reason:%20Unexpected%20end%20of%20JSON%20input to display an error message.

This is bad UX because:

  • You can't just refresh to retry.
  • The history is "overwritten. So you use the URL. For example if you browse down the homepage and open in new tabs you will just lose one of them and won't remember which it is.

Describe the solution you'd like

Just render the error page on the URL that failed to load.

Describe alternatives you've considered

Redirect, but keep the original in the history. But this still isn't as convenient in my opinion.

@kevincox kevincox added the enhancement New feature or request label Feb 10, 2022
@dessalines
Copy link
Member

These are errors that are occurring at the isomorphic layer (IE the server has an error before it can send info back to you). So these are basically a 404 server error page showing you the error in text form.

It might have history, but I'm not sure.

@kevincox
Copy link
Author

I'm not sure what you are trying to say.

I agree that the client should show the error in text form. However I think the URL should not be changed to an "error" URL, it should stay at the page that experienced the error.

@dessalines
Copy link
Member

dessalines commented Feb 14, 2022

Its a server error, so I don't know of a good way to handle it.

Example: lets say you are going to a non-existent community. I can't even begin to load the community page, because the lemmy server will correctly give you an API error saying: "community doesn't exist". So I have to redirect before even trying to load that page, to a 404 page. I can't go "back", because it never loaded the community page in the first place.

@kevincox
Copy link
Author

kevincox commented Feb 14, 2022

I feel like I'm vastly how the Lemmy frontend must work. To me it seems like.

  1. Navigate to a page.
  2. JS attempts to call the API.
  3. Error is encountered.
  4. URL is changed to the error page.
  5. The error is rendered.

My main question is why can't 4 just be skipped. Just render the error page at the original URL. Is this difficult due to a framework limitation?

@dessalines
Copy link
Member

dessalines commented Feb 15, 2022

You skipped a step between 1 and 2, lemmy has what's called an isomorphic ui, where there's a ui "server", that builds the page and fetches all the data on the server, and serves up pre built html without needing javascript. That ui server can only do a redirect when it fails to build the page.

@kevincox
Copy link
Author

I see. But in that case why can't it just generate a prerendered error page withuot the redirect?

@Nutomic
Copy link
Member

Nutomic commented Feb 15, 2022

I agree, its very different when there is some backend error, and you get redirected to some different url. It means you cant just reload, but have to figure out how to get back to the url that you actually wanted to visit. Its even more complicated because it seems to mess up the browser history as well.

@dessalines
Copy link
Member

Okay I found a not-as-pretty but clean way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants