fix: explicitly free connections in case of server errors#45
fix: explicitly free connections in case of server errors#45mattiZed wants to merge 1 commit intowill-ockmore:mainfrom
Conversation
There was a problem hiding this comment.
Thanks for raising this @mattiZed , great writeup.
We need a couple of test cases to verify that we don't get regressions here.
Specifically we should test that we don't leak connections, so these tests fail without your addition.
I'm also wary that this might be happening for responses that are not server errors.
|
Hi @will-ockmore , thanks for looking into this. I got some leverage to contribute here as one of our projects is blocked by this issue - I will look into your tests tomorrow 👍 |
|
Hm, I took a look at it:
Inspecting the connection pool itself I think current tests don't really touch it at all (and probably they shouldn't?) since the tests never really perform actual requests. What do you think? |
|
Mocking the response object is reasonable. It should (I think?) still work to check the connection pool, even with a mocked response; see if that approach is viable. It's clearly a gap in the testing approach and it would be good to plug it with this PR. |
|
So, I had a look yesterday - I just tried to monkeypatch I assume you have a better understanding of the tests alltogether, would you have a look into it? |
|
Great, thanks! |
This fix ensures that connections obtained from
httpxare explicitly closed when the HTTP status code hints at a server error. Fixes #44