Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/content/news.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<span id="news"></span>
# Changelog

## Unreleased

### Bug Fixes

- Worker timeout used to dump a 500 response onto a body that had already
started, because `sys.exit()` from the abort handler is a `BaseException`.
Once headers are out we just close the connection.
([#3410](https://github.com/benoitc/gunicorn/issues/3410)).

## 26.2.0 - 2026-08-24

### New Features
Expand Down
6 changes: 3 additions & 3 deletions gunicorn/workers/base_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ def handle_request(self, listener_name, req, sock, addr):
# If the original exception was a socket.error we delegate
# handling it to the caller (where handle() might ignore it)
util.reraise(*sys.exc_info())
except Exception:
except (Exception, SystemExit):
if resp and resp.headers_sent:
# If the requests have already been sent, we should close the
# connection to indicate the error.
# Timeout abort is SystemExit. If we already started the
# response, writing a 500 on the same socket corrupts it.
self.log.exception("Error handling request")
try:
sock.shutdown(socket.SHUT_RDWR)
Expand Down
6 changes: 3 additions & 3 deletions gunicorn/workers/gthread.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,10 +730,10 @@ def handle_request(self, req, conn):
except OSError:
# pass to next try-except level
util.reraise(*sys.exc_info())
except Exception:
except (Exception, SystemExit):
if resp and resp.headers_sent:
# If the requests have already been sent, we should close the
# connection to indicate the error.
# Timeout abort is SystemExit. If we already started the
# response, writing a 500 on the same socket corrupts it.
self.log.exception("Error handling request")
util.close_graceful(conn.sock)
raise StopIteration()
Expand Down
6 changes: 3 additions & 3 deletions gunicorn/workers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ def handle_request(self, listener, req, client, addr):
except OSError:
# pass to next try-except level
util.reraise(*sys.exc_info())
except Exception:
except (Exception, SystemExit):
if resp and resp.headers_sent:
# If the requests have already been sent, we should close the
# connection to indicate the error.
# Timeout abort is SystemExit. If we already started the
# response, writing a 500 on the same socket corrupts it.
self.log.exception("Error handling request")
util.close_graceful(client)
raise StopIteration()
Expand Down