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

drive: HTTP status 404 behaviour is buggy and unpredictable #712

Open
bep opened this issue Sep 14, 2022 · 3 comments
Open

drive: HTTP status 404 behaviour is buggy and unpredictable #712

bep opened this issue Sep 14, 2022 · 3 comments

Comments

@bep
Copy link

bep commented Sep 14, 2022

This has been a topic before, e.g. with @denydias 's comment in #188 (comment)

That issue is closed, but I have tested this with the Turbo main branch as of yesterday (I notice there have since been some commits).

I see there have been some work on this with the turbo:frame-missing for Turbo Frames, but for Turbo Drive this still leads to a faulty and unpredictable state.

I have a patched version that simply add the 404 to the OK list here:

function isSuccessful(statusCode: number) {

function isSuccessful(statusCode: number) {
  if (statusCode == 404) {
    return true
  }
  return statusCode >= 200 && statusCode < 300
}

I would say that from a rendering perspective (which is Turbo's domain), a 404 is (almost always?) a correct thing to do.

@dhh
Copy link
Member

dhh commented Sep 14, 2022

cc @seanpdoyle

@seanpdoyle
Copy link
Contributor

@bep thank you for opening this issue. Are you able to reproduce this behavior with https://github.com/hotwired/turbo/releases/tag/v7.2.0-rc.2?

@bep
Copy link
Author

bep commented Sep 15, 2022

@seanpdoyle I have tested my app with both v7.2.0-rc.2 and v7.2.0-rc.1. I'm using Turbo with an AlpineJS app, an what I see on 404 errors are some uncaught JS errors indicating a somewhat corrupt state:

image

image

I think this issue is about 2 things:

  1. Whether 404 should be considered an error situation (from a rendering perspective). In my experience, the answer is almost always no (render a 404 page with a linke to the home page or something).
  2. For real errors, Turbo users should be given a way to somehow recover.

This GItHub issue is mostly about 1, and I would be a happy camper if isSuccessful would consider 404 to be a success (or if this could somehow be configured).

@bep bep changed the title drive: HTTP status 404 (and 500?) behaviour is buggy and unpredictable drive: HTTP status 404 behaviour is buggy and unpredictable Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants