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

Show Rails error page for a morph reload #56

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

codergeek121
Copy link
Contributor

I noticed that in contrast to the :replace reload method, :morph will not display the Rails error page if an updated page raises an error. It will only print an error to the browser's console.

I changed the MorphReloader to morph the complete <html> document, to handle the different <head>s between the Rails error page and the app's layout. This would theoretically also fix that a change to an app's layout would not get picked up by the :morph method currently.

While the tests are green, my PR is broken, because after morphing from error page to a fixed version, I get the following browser error: An import map is added after module script load was triggered. and Stimulus controllers run twice.

I decided to open up the PR anyways, to start a discussion about a potential implementation or if someone has an idea how to approach the morph error page. I'll probably take another stab tomorrow and try to use Turbo for the Morph Reloader but I ran out of ideas for today.

* There's still an error after fixing an error and stimulus controller
  load twice after fixing an error
Copy link
Member

@jorgemanrubia jorgemanrubia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @codergeek121.

Showing errors when they happen is a bit disruptive, and silently ignoring them was intentional. It's quite common to introduce syntax errors and such as you work on code. I think it's fine to ignore those until you get things working again and, then, the page can update.

If anything, I'd like to keep the same behavior with the replace option here. Maybe we could subscribe to some turbo event and cancel the visit if there is an error? Not sure if that will be possible with regular Turbo handling, though 🤔.

@codergeek121
Copy link
Contributor Author

Thank you for taking a look.

I can see your point about showing the full error page being too disruptive, especially on fast and small iterative changes. I personally always liked the instant feedback of an error screen similar to e.g. the react error overlay and I always missed a similar feature in the typical Rails setup.

I'll take a look if I can align the :replace method, with a similar error behavior to the :morph method 👍

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

Successfully merging this pull request may close these issues.

2 participants