Repository navigation
Do not log a traceback when a TLS client disconnects mid-response - #1261
Open
Yohan-Senadheera wants to merge 1 commit into
Open
Yohan-Senadheera wants to merge 1 commit into
Yohan-Senadheera wants to merge 1 commit into
Conversation
wsgiref ignores BrokenPipeError and ConnectionResetError when a client goes away during a response, but over TLS the same disconnect raises ssl.SSLEOFError, which is logged with a full traceback even though the server keeps working. Treat it like the other disconnect errors. Fixes prometheus#983 Signed-off-by: Yohan Senadheera <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #983.
When a client drops the connection while
/metricsis being written, wsgiref ignoresBrokenPipeErrorandConnectionResetError. Over TLS the same disconnect raisesssl.SSLEOFError, which wsgiref does not ignore, sohandle_error()prints a full traceback. The server keeps working, but the traceback looks like a crash (as in #983).This adds a
ServerHandlersubclass whosehandle_error()ignoresSSLEOFErrorthe same way, and_SilentHandler.handle()uses it.handle()is the same asWSGIRequestHandler.handle()apart from the handler class.Tested with
start_http_server(certfile=..., keyfile=...)and a TLS client that resets the connection after the first bytes, three times:ssl.SSLEOFError: EOF occurred in violation of protocolThe new tests check that
SSLEOFErroris not logged and that other errors still are. The full test suite, flake8 and isort pass.