-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: handle OSError on failure to close socket instead of raising IndexError #114
Conversation
It is possible for `loop.sock_connect` to fail in such a way that the wrapped socket no longer refers to a valid file descriptor. In this, the exception handler can fail on the attempt to call `sock.close()`. When this happens, `start_connection` can have `sock == None` and `exceptions == []`. This causes an `IndexError` because it assumes that `exceptions` always contains at least one exception instance.
Fix for type checker
Would you please post the full trace you get when it raises I'll try to get the code coverage reporting fixed |
I bumped the codecov-action in #115 so hopefully codecov will work again once this PR has tests added |
codecov reporting should work now if you update with main |
Ah yes, I believe this is the same issue. This started happening to us in production and the closest I have been able to come to a standalone test case is to generate statistically similar traffic patterns (which in our case means fairly aggressive timeouts). I haven't been able yet to craft a self-contained unit test. |
chore: bump codecov-action to 5.0.3 (aio-libs#115)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #114 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 227 235 +8
Branches 60 60
=========================================
+ Hits 227 235 +8 ☔ View full report in Codecov by Sentry. |
You should still be able to provide the stacktrace from the logs though? That gives a starting point for us to look at. |
I think when I have seen this error, it is generated as a side effect of the uvloop issue MagicStack/uvloop#645. Not sure how helpful the stack trace is:
|
It might make more sense to wait for |
Certainly can, but I don't think this papers over anything, just avoids the extraneous |
Nevermind, I was overthinking it. The exception will still get re-raised at the end. So I think this is OK to merge once we have test coverage |
Don't worry about the individual commit messages. I'll squash it before merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @todddialpad
What do these changes do?
It is possible for
loop.sock_connect
to fail in such a way that the wrapped socket no longer refers to a valid file descriptor. In this, the exception handler can fail on the attempt to callsock.close()
. When this happens,start_connection
can havesock == None
andexceptions == []
. This causes anIndexError
because it assumes thatexceptions
always contains at least one exception instance.Are there changes in behavior for the user?
I experienced crashes when handling connections with short timeouts.
Related issue number
Checklist