{"action":"created","issue":{"url":"https://api.github.com/repos/ruby/webrick/issues/9","repository_url":"https://api.github.com/repos/ruby/webrick","labels_url":"https://api.github.com/repos/ruby/webrick/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/ruby/webrick/issues/9/comments","events_url":"https://api.github.com/repos/ruby/webrick/issues/9/events","html_url":"https://github.com/ruby/webrick/issues/9","id":319749176,"node_id":"MDU6SXNzdWUzMTk3NDkxNzY=","number":9,"title":"raising unhandled `Exception` returns 200 status code","user":{"login":"gabetax","id":149842,"node_id":"MDQ6VXNlcjE0OTg0Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/149842?v=4","gravatar_id":"","url":"https://api.github.com/users/gabetax","html_url":"https://github.com/gabetax","followers_url":"https://api.github.com/users/gabetax/followers","following_url":"https://api.github.com/users/gabetax/following{/other_user}","gists_url":"https://api.github.com/users/gabetax/gists{/gist_id}","starred_url":"https://api.github.com/users/gabetax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabetax/subscriptions","organizations_url":"https://api.github.com/users/gabetax/orgs","repos_url":"https://api.github.com/users/gabetax/repos","events_url":"https://api.github.com/users/gabetax/events{/privacy}","received_events_url":"https://api.github.com/users/gabetax/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-05-02T23:51:06Z","updated_at":"2018-09-28T02:30:11Z","closed_at":"2018-09-28T00:22:43Z","author_association":"NONE","body":"Given this rack app\r\n\r\n```ruby\r\nrun Proc.new { raise Exception }\r\n```\r\n\r\nRun with\r\n\r\n```\r\nrackup -s webrick exception_200.ru\r\n[2018-05-02 16:41:36] INFO  WEBrick 1.4.2\r\n[2018-05-02 16:41:36] INFO  ruby 2.5.0 (2017-12-25) [x86_64-darwin16]\r\n[2018-05-02 16:41:36] INFO  WEBrick::HTTPServer#start: pid=36207 port=9292\r\n[2018-05-02 16:41:59] ERROR Exception: Exception\r\n\t/Users/gmartin-dempesy/x/exception_200.ru:1:in `block (2 levels) in <main>'\r\n```\r\n\r\nReturns this response\r\n\r\n```\r\ncurl -v 0:9292\r\n* Rebuilt URL to: 0:9292/\r\n*   Trying 0.0.0.0...\r\n* TCP_NODELAY set\r\n* Connected to 0 (127.0.0.1) port 9292 (#0)\r\n> GET / HTTP/1.1\r\n> Host: 0:9292\r\n> User-Agent: curl/7.54.0\r\n> Accept: */*\r\n>\r\n< HTTP/1.1 200 OK\r\n< Server: WEBrick/1.4.2 (Ruby/2.5.0/2017-12-25)\r\n< Date: Wed, 02 May 2018 23:41:58 GMT\r\n< Content-Length: 0\r\n< Connection: Keep-Alive\r\n<\r\n* Connection #0 to host 0 left intact\r\n```\r\n\r\nI stumbled on this behavior in a Rails app running in the test environment, which by default raises errors due to `config.action_dispatch.show_exceptions = false`, and a gem that wasn't subclassing its custom exceptions from `StandardError`.\r\n\r\nI believe the gap is this area of code: https://github.com/ruby/webrick/blob/7b2c8069e3274559b20061aea28deb038d47a6d3/lib/webrick/httpserver.rb#L104-L106\r\n\r\nI think we're all on the same page that rescuing `Exception` is not idiomatic due to signal and hardware related exceptions, but the current false-positive acknowledgment situation is dangerous and can cause lost writes.\r\n\r\nI'd pitch either:\r\n\r\n1. Rescue `Exception` instead of `StandardError` when setting the status code\r\n2. Hard-crash, and don't provide any response."},"comment":{"url":"https://api.github.com/repos/ruby/webrick/issues/comments/425301120","html_url":"https://github.com/ruby/webrick/issues/9#issuecomment-425301120","issue_url":"https://api.github.com/repos/ruby/webrick/issues/9","id":425301120,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTMwMTEyMA==","user":{"login":"hsbt","id":12301,"node_id":"MDQ6VXNlcjEyMzAx","avatar_url":"https://avatars1.githubusercontent.com/u/12301?v=4","gravatar_id":"","url":"https://api.github.com/users/hsbt","html_url":"https://github.com/hsbt","followers_url":"https://api.github.com/users/hsbt/followers","following_url":"https://api.github.com/users/hsbt/following{/other_user}","gists_url":"https://api.github.com/users/hsbt/gists{/gist_id}","starred_url":"https://api.github.com/users/hsbt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hsbt/subscriptions","organizations_url":"https://api.github.com/users/hsbt/orgs","repos_url":"https://api.github.com/users/hsbt/repos","events_url":"https://api.github.com/users/hsbt/events{/privacy}","received_events_url":"https://api.github.com/users/hsbt/received_events","type":"User","site_admin":false},"created_at":"2018-09-28T02:30:11Z","updated_at":"2018-09-28T02:30:11Z","author_association":"MEMBER","body":"@gabetax I did update its url at https://github.com/ruby/webrick/commit/082b6345c2fda320d9a3e6fa09fa7614dd3a5575. Thanks!"}}
{"actor":{"display_login":"hsbt"}}