Skip to content

Instantly share code, notes, and snippets.

@digitalm
Last active April 22, 2022 07:51
Show Gist options
  • Save digitalm/2c31447c0cb4968129b826454ebb5e1c to your computer and use it in GitHub Desktop.
Save digitalm/2c31447c0cb4968129b826454ebb5e1c to your computer and use it in GitHub Desktop.
development モードで 504 gateway timeout を受け取るためのイージーな方法

https://github.com/sharpstone/rack-timeout 使う

  1. Gemfile
group :development do
  gem 'rack-timeout'
end
  1. .env
# 1 second
RACK_TIMEOUT_SERVICE_TIMEOUT=1
  1. config/environments/development.rb
Rails.application.configure do
  config.action_dispatch.rescue_responses["Rack::Timeout::RequestTimeoutException"] = :gateway_timeout
  ...

結果 =>

Processing by SessionsController#new as HTML
  Rendering layout layouts/application.html.slim
  Rendering sessions/new.html.slim within layouts/application
  Rendered sessions/new.html.slim within layouts/application (Duration: 103.4ms | Allocations: 45561)
source=rack-timeout id=924ea792-3653-4aa8-a305-7eaa051e685a timeout=1000ms service=1068ms state=active
source=rack-timeout id=924ea792-3653-4aa8-a305-7eaa051e685a timeout=1000ms service=1245ms state=timed_out
  Rendered layout layouts/application.html.slim (Duration: 1243.9ms | Allocations: 185715)
Completed 504 Gateway Timeout in 1349ms (ActiveRecord: 0.0ms | Allocations: 225358)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment