Rack::timout
Rack::Timeout is not a solution to the problem of long-running requests, it's a debug and remediation tool
記事
注意
Rack::timoutより以前に読み込まれたmiddlewareでReDoSが発生した場合はタイムアウト出来ない code:config.ru
require "rack-timeout"
class Redos
def initialize(app, options = {})
@app = app
end
def call(env)
("\t" * 100000 +"\ta,a\t").split(/\s*,\s*/)
@app.call(env)
end
end
class Server
def call(env)
[200, {}, []]
end
end
# use Redos # Rack::Timeoutでのタイムアウトが動作しない
use Rack::Timeout, service_timeout: 5
use Redos # Rack::Timeoutでのタイムアウトが動作する
run Server.new
Rack::Timeoutより後のmiddlewareで発生したReDoSに対してはタイムアウトが機能する
code:log
❯ bundle exec puma
...
^C- Gracefully stopping, waiting for requests to finish