From e272a384cea3d9d7a0a1fba257cc50c730e6aa7b Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 9 Sep 2024 19:13:29 +0300 Subject: [PATCH] Respond to timeouts with a server error code --- app/controllers/application_controller.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8290a027e..fdc2ac4e8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -224,14 +224,17 @@ class ApplicationController < ActionController::Base if e.is_a?(Timeout::Error) || (e.is_a?(ActiveRecord::StatementInvalid) && e.message.include?("execution expired")) - ActiveRecord::Base.connection.raw_connection.cancel - render :action => "timeout" + respond_to_timeout else raise end rescue Timeout::Error + respond_to_timeout + end + + def respond_to_timeout ActiveRecord::Base.connection.raw_connection.cancel - render :action => "timeout" + render :action => "timeout", :status => :gateway_timeout end ## -- 2.39.5