mirror of
https://github.com/postalserver/postal.git
synced 2026-12-05 15:55:50 +00:00
When a client disconnects abruptly, OpenSSL and the socket layer raise
errors that the SMTP server logged as genuine server errors (with a full
backtrace and Sentry report) despite being routine client-gone events -
commonly caused by port scanners, load-balancer health checks and
senders whose connection drops.
Three paths in the event loop were affected:
- Handshake path: a client resetting the connection mid SSL_accept
raises Errno::ECONNRESET (not an SSLError), which the handshake
rescue did not handle.
- Read path: an abrupt disconnect while reading raises
OpenSSL::SSL::SSLError ("SSL_read: unexpected eof while reading")
rather than an EOFError, which the read rescue did not handle.
- Write path: a client gone before the response is written raises
Errno::EPIPE ("broken pipe") as well as the already-handled
Errno::ECONNRESET.
Extend each rescue so an abrupt disconnect on any path is treated the
same as a plain EOF: the connection is closed quietly instead of being
reported as a server error.
Co-authored-by: kiku98 <github@kiliankunkel.de>