Skip to content

Lucky::TextResponse#print raises exception if the client has gone away. #1608

@BrucePerens

Description

@BrucePerens

context.response.print body

This raises IO::Error if the client has gone away and there is no longer a valid socket to write to. It should catch IO::Error and simply log that the client went away before the response could be sent. Perhaps the error should be handled in HTTP::Server rather than Lucky. The backtrace is:

▸ Rendered Page::Search::Product::Result
 ▸  IO::Error 

     Error writing to socket: Broken pipe

    Backtrace 

/usr/share/crystal/src/io/evented.cr:82:13 in 'unbuffered_write'
     /usr/share/crystal/src/io/buffered.cr:152:14 in 'write'
     /usr/share/crystal/src/http/server/response.cr:223:11 in 'unbuffered_write'
     /usr/share/crystal/src/io/buffered.cr:152:14 in 'write'
     /usr/share/crystal/src/http/server/response.cr:86:7 in 'write'
     /usr/share/crystal/src/io/memory.cr:412:5 in 'to_s'
     /usr/share/crystal/src/io.cr:174:5 in '<<'
     /usr/share/crystal/src/io.cr:188:5 in 'print'
     lib/lucky/src/lucky/text_response.cr:32:5 in 'print'
     lib/lucky/src/lucky/renderable.cr:145:5 in 'handle_response'
     lib/lucky/src/lucky/renderable.cr:140:5 in 'perform_action'
     lib/lucky/src/lucky/route_handler.cr:10:7 in 'call'
     /usr/share/crystal/src/http/server/request_processor.cr:51:11 in 'process'
     /usr/share/crystal/src/http/server.cr:515:5 in 'handle_client'
     /usr/share/crystal/src/http/server.cr:468:13 in '->'
     /usr/share/crystal/src/primitives.cr:266:3 in 'run'
     /usr/share/crystal/src/fiber.cr:92:34 in '->'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions