From fd853c7a335e2da40a20ad1f041f945d09a5651f Mon Sep 17 00:00:00 2001 From: zz9pzza Date: Mon, 2 Dec 2019 03:08:51 +0000 Subject: [PATCH] AO3-5832 Return 444 for Elasticsearch errors (#3701) * Redirect Elasticsearch::Transport::Transport::Errors::ServiceUnavailable to our custom error * Follow the hound * AO3-5832 Add a comment for 444 --- app/controllers/application_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f930b5df04c..9c90d2ee18c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,6 +4,11 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception, prepend: true rescue_from ActionController::InvalidAuthenticityToken, with: :display_auth_error rescue_from ActionController::UnknownFormat, with: :raise_not_found + rescue_from Elasticsearch::Transport::Transport::Errors::ServiceUnavailable do + # Non-standard code used by nginx: closes a connection without sending + # a response header. + head 444 + end def raise_not_found redirect_to '/404'