From: Anton Khorev Date: Mon, 9 Sep 2024 16:13:29 +0000 (+0300) Subject: Respond to timeouts with a server error code X-Git-Tag: live~122^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/e272a384cea3d9d7a0a1fba257cc50c730e6aa7b Respond to timeouts with a server error code --- 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 ##