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

AO3-6911 Add error page for Rack::Timeout::RequestTimeoutException #5074

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

boyer-victor
Copy link
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-6911

Purpose

  1. Add a page under /timeout that is returned should the app controller encounter Rack::Timeout::RequestTimeoutException.
  2. Added a test that the page is rendered on that route.
  3. Added a test that the auth_error page is rendered on its route to errors_controller_spec.rb

Testing Instructions

Needs Systems change, see story for details

I added a unit test that this page can be routed too, but I do not think there is a way to test the actual timeout rescue except from an integration test. See the docs here. If I'm missing something or if we have a method for setting up such tests already that someone could point me too it would be much appreciated.

Credit

unsafe-deref, he/him

@boyer-victor
Copy link
Contributor Author

I am ignoring the reviewdog comments on single v double quotes as in all instances using single quotes matches the existing page styling or the recommended page to adapt from (re: 500 error page).

@redsummernight
Copy link
Member

Please do address the reviewdog comments on the parts that you've added or changed. It's fine to deviate from the existing 500 error page in terms of code style.

You don't have to fix any of the existing lint violations, however.

@redsummernight redsummernight changed the title AO3-6911: add timeout page for Rack::Timeout::RequestTimeoutException AO3-6911 Add error page for Rack::Timeout::RequestTimeoutException Feb 21, 2025
@@ -8,4 +8,8 @@ class ErrorsController < ApplicationController
def auth_error
@page_subtitle = "Auth Error"
end

def timeout_error
@page_subtitle = "Timeout Error"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also i18n this. Here is an example:

@page_subtitle = t(".page_title")
+
page_title: Privacy Policy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Apologies, I am used to a different pattern and did not look carefully enough at the locale specs for this project. I updated auth_error as well.

config/routes.rb Outdated
@@ -53,6 +53,7 @@
get '/422', to: 'errors#422'
get '/500', to: 'errors#500'
get '/auth_error', to: 'errors#auth_error'
get "/timeout", to: "errors#timeout"
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to have the name of the controller action in the to option, and then lets match the auth_error for the get

Suggested change
get "/timeout", to: "errors#timeout"
get "/timeout_error", to: "errors#timeout_error"

The reason the test didn't fail is because by default, even if there is no method in the controller, Rails renders the HTML template with the action name, which is timeout.html.erb. The html.erb should also be renamed to timeout_error.html.erb to match the controller (and the auth error).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tricky, I would prefer just a failure than a default loading that is non-obvious. Thanks for pointing it out, resolved.

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

Successfully merging this pull request may close these issues.

4 participants