-
Notifications
You must be signed in to change notification settings - Fork 431
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
Allow opt-in to breaking out of missing frames #864
Closed
Closed
Commits on Feb 2, 2023
-
Don't break out of frames when frame missing
This changes the default behaviour when a frame response is missing its expected `<turbo-frame>` element. Previously, when the response was missing its frame, we would trigger a `turbo:frame-missing` event, and then (provided that event wasn't cancelled) perform a full page visit to the requested URL. However there are cases where the full reload makes things worse: - If the frame contents were non-critical, reloading the page can turn a minor bug into a major one. - It can mask some bugs where frames were intend to explicitly navigate out of the frame (`target="_top"`), by incurring a second request that loads the page that makes it seem as if it's working corrects. - It leaves the user at a URL that may never be capable of rendering a valid response (since that URL was only intended to serve a particular frame). That means refreshing the page is no help in getting back to a working state. - It can lose other temporary state on a page, like form values. With this change, we no longer perform the full page visit. Instead, we handle a missing frame by doing two things: - Write a short error message into the frame, so that the problem is visible on the page. - Throw an exception, which should make the problem quite obvious in development, and which allows it to be easily gathered by exception monitoring tools in production. We keep the `turbo:frame-missing` event exactly as before, so applications can still hook in to perform alternative behaviour if they want.
Configuration menu - View commit details
-
Copy full SHA for 524482d - Browse repository at this point
Copy the full SHA 524482dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6cdc254 - Browse repository at this point
Copy the full SHA 6cdc254View commit details
Commits on Feb 3, 2023
-
Use view to render frame missing message
Also remove `invalidate` that has effectively been replaced.
Configuration menu - View commit details
-
Copy full SHA for e2542eb - Browse repository at this point
Copy the full SHA e2542ebView commit details -
Allow opt-in to breaking out of missing frames
When a frame response is missing its expected `turbo-frame` element, we consider it an error. Normally this is what we want. In certain cases, though, it's better if a response without a matching frame is treated as a full page instead. The classic example of this is a login page being rendered in response to an expired session. To allow this, we provide a way for a page to mark itself as "breakoutable" by including a specific meta tag in its head: <meta name="turbo-frame-missing" content="visit"> When a response is missing its expected frame, but includes that meta tag, we'll perform a full-page visit to it, rather than throw an error.
Configuration menu - View commit details
-
Copy full SHA for 91755b8 - Browse repository at this point
Copy the full SHA 91755b8View commit details -
Specify breakoutable frames in requesting page
Rather than use a meta tag in the response, we can put a central list of "breakoutable" paths in a single meta tag, and include that on requesting pages. Assuming that an application will have a small number of these paths, it might be simpler to centralise them in one place and include that in a shared layout.
Configuration menu - View commit details
-
Copy full SHA for c5fec57 - Browse repository at this point
Copy the full SHA c5fec57View commit details -
Configuration menu - View commit details
-
Copy full SHA for c567587 - Browse repository at this point
Copy the full SHA c567587View commit details -
Configuration menu - View commit details
-
Copy full SHA for d64b279 - Browse repository at this point
Copy the full SHA d64b279View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.