-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't break out of frames when frame missing (#863)
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.
- Loading branch information
1 parent
a7d6566
commit 91ee8f6
Showing
4 changed files
with
39 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class TurboFrameMissingError extends Error {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters