mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Handle fatal error that has no backtrace (#2607)
* handle low level error that has no backtrace * add force_shutdown_after in test case * skip test on windows for low level error * remove extra space * remove two extra lines * rename test method to lowlevel_error
This commit is contained in:
parent
a717b27354
commit
a02f9241ae
2 changed files with 21 additions and 1 deletions
|
@ -528,7 +528,8 @@ module Puma
|
|||
end
|
||||
|
||||
if @leak_stack_on_error
|
||||
[status, {}, ["Puma caught this error: #{e.message} (#{e.class})\n#{e.backtrace.join("\n")}"]]
|
||||
backtrace = e.backtrace.nil? ? '<no backtrace available>' : e.backtrace.join("\n")
|
||||
[status, {}, ["Puma caught this error: #{e.message} (#{e.class})\n#{backtrace}"]]
|
||||
else
|
||||
[status, {}, ["An unhandled lowlevel error occurred. The application logs may have details.\n"]]
|
||||
end
|
||||
|
|
|
@ -285,6 +285,25 @@ EOF
|
|||
assert_match(/{}\n$/, data)
|
||||
end
|
||||
|
||||
def test_lowlevel_error_message
|
||||
skip_if :windows
|
||||
@server = Puma::Server.new @app, @events, {:force_shutdown_after => 2}
|
||||
|
||||
server_run app: ->(env) do
|
||||
require 'json'
|
||||
|
||||
# will raise fatal: machine stack overflow in critical region
|
||||
obj = {}
|
||||
obj['cycle'] = obj
|
||||
::JSON.dump(obj)
|
||||
end
|
||||
|
||||
data = send_http_and_read "GET / HTTP/1.0\r\n\r\n"
|
||||
|
||||
assert_match(/HTTP\/1.0 500 Internal Server Error/, data)
|
||||
assert (data.size > 0), "Expected response message to be not empty"
|
||||
end
|
||||
|
||||
def test_force_shutdown_error_default
|
||||
@server = Puma::Server.new @app, @events, {:force_shutdown_after => 2}
|
||||
|
||||
|
|
Loading…
Reference in a new issue