Skip to content

Unhandled server.accept() exception crashes the entire event loop #7

Description

@maedi

`LowLoop#start` (lib/low_loop.rb:49-58) only rescues exceptions from `handle_connection`:

loop do
  socket = server.accept          # not covered by the rescue below

  task.async do
    handle_connection(socket)
  rescue StandardError => e
    render_error(e)
  ensure
    socket&.close
  end
end

`server.accept` itself is outside that rescue. Real TCP servers hit accept() failures under load — Errno::EMFILE/ENFILE (fd exhaustion), Errno::ECONNABORTED (client resets mid-handshake). Any of these propagates out of `loop`, out of the `Async` block, and up through `LowLoop#start` uncaught. `bin/server` calls `.start` with no surrounding rescue, so one transient accept() failure takes down every in-flight connection on the server, not just the one that triggered it.

Suggested fix: wrap the `accept` call (or the whole loop body) in its own rescue so a single accept() failure logs/backs off rather than killing the reactor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions