Open itsezc opened 3 years ago
I have the same issue. How to reproduce (don't know if it works on your environment):
setup local server (build using kemal), then start the process on terminal
open Firefox then go to the home url of your site, for example mine is http://0.0.0.0:8080/
click any link to go to other page, for example http://0.0.0.0:8080/page1
open terminal, press CTLR+C to shutdown your server process
start a new server instance
go to the browser, click the back button to go 1 level of history (ex http://0.0.0.0:8080/)
check to kemal error log
Exception: Error while writing data to the client (HTTP::Server::ClientError)
from ../../../../../usr/share/crystal/src/http/server/response.cr:216:9 in 'unbuffered_write'
from ../../../../../usr/share/crystal/src/io/buffered.cr:152:14 in 'write'
from ../../../../../usr/share/crystal/src/http/server/response.cr:86:7 in 'write'
from ../../../../../usr/share/crystal/src/io.cr:470:7 in 'write_utf8'
from ../../../../../usr/share/crystal/src/string.cr:4961:5 in 'to_s'
from ../../../../../usr/share/crystal/src/io.cr:174:5 in '<<'
from ../../../../../usr/share/crystal/src/io.cr:188:5 in 'print'
from lib/kemal/src/kemal/route_handler.cr:55:7 in 'process_request'
from lib/kemal/src/kemal/route_handler.cr:17:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from lib/kemal/src/kemal/websocket_handler.cr:13:14 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from lib/kemal/src/kemal/filter_handler.cr:21:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from lib/kemal/src/kemal/exception_handler.cr:8:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from ../../../../../usr/share/crystal/src/http/server/handlers/static_file_handler.cr:103:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from lib/kemal/src/kemal/null_log_handler.cr:5:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from lib/kemal/src/kemal/init_handler.cr:12:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/request_processor.cr:50:11 in 'process'
from ../../../../../usr/share/crystal/src/http/server.cr:513:5 in 'handle_client'
from ../../../../../usr/share/crystal/src/http/server.cr:468:13 in '->'
from ../../../../../usr/share/crystal/src/primitives.cr:255:3 in 'run'
from ../../../../../usr/share/crystal/src/fiber.cr:92:34 in '->'
from ???
Caused by: Error writing to socket: Broken pipe (IO::Error)
from ../../../../../usr/share/crystal/src/io/evented.cr:82:13 in 'unbuffered_write'
from ../../../../../usr/share/crystal/src/io/buffered.cr:152:14 in 'write'
from ../../../../../usr/share/crystal/src/http/server/response.cr:209:11 in 'unbuffered_write'
from ../../../../../usr/share/crystal/src/io/buffered.cr:152:14 in 'write'
from ../../../../../usr/share/crystal/src/http/server/response.cr:86:7 in 'write'
from ../../../../../usr/share/crystal/src/io.cr:470:7 in 'write_utf8'
from ../../../../../usr/share/crystal/src/string.cr:4961:5 in 'to_s'
from ../../../../../usr/share/crystal/src/io.cr:174:5 in '<<'
from ../../../../../usr/share/crystal/src/io.cr:188:5 in 'print'
from lib/kemal/src/kemal/route_handler.cr:55:7 in 'process_request'
from lib/kemal/src/kemal/route_handler.cr:17:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from lib/kemal/src/kemal/websocket_handler.cr:13:14 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from lib/kemal/src/kemal/filter_handler.cr:21:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from lib/kemal/src/kemal/exception_handler.cr:8:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from ../../../../../usr/share/crystal/src/http/server/handlers/static_file_handler.cr:103:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from lib/kemal/src/kemal/null_log_handler.cr:5:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next'
from lib/kemal/src/kemal/init_handler.cr:12:7 in 'call'
from ../../../../../usr/share/crystal/src/http/server/request_processor.cr:50:11 in 'process'
from ../../../../../usr/share/crystal/src/http/server.cr:513:5 in 'handle_client'
from ../../../../../usr/share/crystal/src/http/server.cr:468:13 in '->'
from ../../../../../usr/share/crystal/src/primitives.cr:255:3 in 'run'
from ../../../../../usr/share/crystal/src/fiber.cr:92:34 in '->'
from ???
There are some reports on this link https://github.com/crystal-lang/crystal/issues/9065
I have the same issue. How to reproduce (don't know if it works on your environment):
setup local server (build using kemal), then start the process on terminal open Firefox then go to the home url of your site, for example mine is http://0.0.0.0:8080/ click any link to go to other page, for example http://0.0.0.0:8080/page1 open terminal, press CTLR+C to shutdown your server process start a new server instance go to the browser, click the back button to go 1 level of history (ex http://0.0.0.0:8080/) check to kemal error log
Exception: Error while writing data to the client (HTTP::Server::ClientError) from ../../../../../usr/share/crystal/src/http/server/response.cr:216:9 in 'unbuffered_write' from ../../../../../usr/share/crystal/src/io/buffered.cr:152:14 in 'write' from ../../../../../usr/share/crystal/src/http/server/response.cr:86:7 in 'write' from ../../../../../usr/share/crystal/src/io.cr:470:7 in 'write_utf8' from ../../../../../usr/share/crystal/src/string.cr:4961:5 in 'to_s' from ../../../../../usr/share/crystal/src/io.cr:174:5 in '<<' from ../../../../../usr/share/crystal/src/io.cr:188:5 in 'print' from lib/kemal/src/kemal/route_handler.cr:55:7 in 'process_request' from lib/kemal/src/kemal/route_handler.cr:17:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from lib/kemal/src/kemal/websocket_handler.cr:13:14 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from lib/kemal/src/kemal/filter_handler.cr:21:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from lib/kemal/src/kemal/exception_handler.cr:8:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from ../../../../../usr/share/crystal/src/http/server/handlers/static_file_handler.cr:103:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from lib/kemal/src/kemal/null_log_handler.cr:5:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from lib/kemal/src/kemal/init_handler.cr:12:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/request_processor.cr:50:11 in 'process' from ../../../../../usr/share/crystal/src/http/server.cr:513:5 in 'handle_client' from ../../../../../usr/share/crystal/src/http/server.cr:468:13 in '->' from ../../../../../usr/share/crystal/src/primitives.cr:255:3 in 'run' from ../../../../../usr/share/crystal/src/fiber.cr:92:34 in '->' from ??? Caused by: Error writing to socket: Broken pipe (IO::Error) from ../../../../../usr/share/crystal/src/io/evented.cr:82:13 in 'unbuffered_write' from ../../../../../usr/share/crystal/src/io/buffered.cr:152:14 in 'write' from ../../../../../usr/share/crystal/src/http/server/response.cr:209:11 in 'unbuffered_write' from ../../../../../usr/share/crystal/src/io/buffered.cr:152:14 in 'write' from ../../../../../usr/share/crystal/src/http/server/response.cr:86:7 in 'write' from ../../../../../usr/share/crystal/src/io.cr:470:7 in 'write_utf8' from ../../../../../usr/share/crystal/src/string.cr:4961:5 in 'to_s' from ../../../../../usr/share/crystal/src/io.cr:174:5 in '<<' from ../../../../../usr/share/crystal/src/io.cr:188:5 in 'print' from lib/kemal/src/kemal/route_handler.cr:55:7 in 'process_request' from lib/kemal/src/kemal/route_handler.cr:17:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from lib/kemal/src/kemal/websocket_handler.cr:13:14 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from lib/kemal/src/kemal/filter_handler.cr:21:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from lib/kemal/src/kemal/exception_handler.cr:8:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from ../../../../../usr/share/crystal/src/http/server/handlers/static_file_handler.cr:103:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from lib/kemal/src/kemal/null_log_handler.cr:5:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/handler.cr:28:7 in 'call_next' from lib/kemal/src/kemal/init_handler.cr:12:7 in 'call' from ../../../../../usr/share/crystal/src/http/server/request_processor.cr:50:11 in 'process' from ../../../../../usr/share/crystal/src/http/server.cr:513:5 in 'handle_client' from ../../../../../usr/share/crystal/src/http/server.cr:468:13 in '->' from ../../../../../usr/share/crystal/src/primitives.cr:255:3 in 'run' from ../../../../../usr/share/crystal/src/fiber.cr:92:34 in '->' from ???
There are some reports on this link crystal-lang/crystal#9065
may be file's path incorrect
should be -> /path/to/your/file/from/parent/directory/
The Error writing to socket: Broken pipe (IO::Error)
error most likely occurs when the client disconnects before the server fulfils the request. IIRC in most cases is rather harmless and can be ignored.
See https://github.com/crystal-lang/crystal/pull/9034#discussion_r406977081 and https://github.com/crystal-lang/crystal/pull/9115#discussion_r412258095.
I think this issue can safely be closed.
It's an issue for high traffic applications, you are flooded by these logs, and you can't read the other useful lines of log.
In invidious, we had to override the class in order to not get these exceptions: https://github.com/iv-org/invidious/blob/master/src/invidious/helpers/crystal_class_overrides.cr#L51
Otherwise, on a high traffic application we would get these errors every second: https://github.com/iv-org/invidious/issues/1416
For me, it is still worth it to keep this issue open until we find a configurable parameter to mute these errors. Kemal is the only library where I have seen these error logs, I have never seen such logs in other libraries in other programming language.
Hey @unixfox thanks a lot for the feedback, I'll reopen the issue. @straight-shoota do you have any idea if we can do anything about this in std-lib or kemal itself?
Description
Throws various errors related to HTTP::Server and IO:Error however the content loads and works.
Steps to Reproduce
Expected behavior: No errors thrown, as the code is very basic and taken directly from the docs.
Actual behavior:
Reproduces how often: Everytime
Versions
OS: Mac OS Catalina