fix(aio): handle socket_action errors in _force_timeout - #818
Open
disqualifier wants to merge 1 commit into
Open
fix(aio): handle socket_action errors in _force_timeout#818disqualifier wants to merge 1 commit into
disqualifier wants to merge 1 commit into
Conversation
_force_timeout drives curl_multi_socket_action every ~100ms so a missing socket or timer event cannot stall a request indefinitely. It called socket_action() without handling errors, and a non-OK return raises CurlError. Nothing caught it, so the coroutine ended and was never restarted, leaving the safeguard stopped for the rest of the session. Catch the error, report it as a CurlCffiWarning, and keep the loop running. Co-Authored-By: Zachary Lile <zacklile@hotmail.com> Signed-off-by: disqualifier <dev@disqualifier.me>
disqualifier
force-pushed
the
fix/force-timeout-socket-action-error
branch
from
August 2, 2026 04:07
f8bf2f2 to
1545136
Compare
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.
_force_timeoutexists to make sure a missing socket or timer event neverstalls indefinitely. It runs in the background and drives
curl_multi_socket_actionevery ~100ms, so if a wakeup is ever missed, thenext tick recovers it.
Problem
It calls
socket_action()without handling errors, andsocket_action()raises
CurlErroron a non-OK return. Nothing catches it, so the coroutineends. It is never restarted, which leaves the safeguard stopped for the rest
of the session. Nothing recovers a missed wakeup after that, so a request
that only needed the next tick to make progress can stall and hang the caller.
Fix
Handle the error inside
_force_timeout. Ifsocket_action()fails, reportit as a
CurlCffiWarningand keep the loop running, so the safeguard keepsdoing its job instead of ending on the first error. The request-path calls
that raise
CurlErroron purpose (add_handleand similar) are leftunchanged.
Test
tests/unittest/test_async.py::test_force_timeout_errorinjects one failingsocket_actioncall and checks the safeguard is still running afterward. Itfails on
mainand passes with this change.Open question
process_datacallsself.socket_action()the same way, outside its owntry, so the sameCurlErrorgoes unhandled there too. With_force_timeoutfixed its next tick recovers that socket, so I left it alone to keep this
small. Want the same handling on
process_data, or a follow-up?Checklist