Skip to content
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

Errors with aiohttp 3.8.6 #207

Closed
oschwald opened this issue Oct 19, 2023 · 5 comments
Closed

Errors with aiohttp 3.8.6 #207

oschwald opened this issue Oct 19, 2023 · 5 comments

Comments

@oschwald
Copy link

With the recent 3.8.6 release of aiohttp, we have started seeing errors such as this with mocket:

self = <ClientResponse(https://minfraud.maxmind.com/minfraud/v2.0/transactions/report) [None None]>
None

connection = Connection<ConnectionKey(host='minfraud.maxmind.com', port=443, is_ssl=True, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=-4230833992692997272)>

    async def start(self, connection: "Connection") -> "ClientResponse":
        """Start response processing."""
        self._closed = False
        self._protocol = connection.protocol
        self._connection = connection

        with self._timer:
            while True:
                # read response
                try:
                    protocol = self._protocol
                    message, payload = await protocol.read()  # type: ignore[union-attr]
                except http.HttpProcessingError as exc:
>                   raise ClientResponseError(
                        self.request_info,
                        self.history,
                        status=exc.code,
                        message=exc.message,
                        headers=exc.headers,
                    ) from exc
E                   aiohttp.client_exceptions.ClientResponseError: 400, message="Data after `Connection: close`:\n\n  b'null'\n     ^", url=URL('https://minfraud.maxmind.com/minfraud/v2.0/transactions/report')

../../.pyenv/versions/3.10.12/lib/python3.10/site-packages/aiohttp/client_reqrep.py:925: ClientResponseError

Although I am not 100% sure mocket is at fault, we haven't had any reports of errors in real use. You can see an example build here.

@mindflayer
Copy link
Owner

Hi @oschwald,
I've just run twice the whole test-suite and it worked like a charm.
I'll have a look at your specific error, anyway.

[...]

---------- coverage: platform linux, python 3.11.4-final-0 -----------
Name                                   Stmts   Miss  Cover   Missing
--------------------------------------------------------------------
mocket/__init__.py                         4      0   100%
mocket/async_mocket.py                     7      0   100%
mocket/compat.py                          18      0   100%
mocket/exceptions.py                       4      0   100%
mocket/mocket.py                         432     13    97%   103-105, 134, 216, 231-236, 251, 344, 487
mocket/mockhttp.py                       149      1    99%   69
mocket/mockredis.py                       52      0   100%
mocket/plugins/__init__.py                 0      0   100%
mocket/plugins/httpretty/__init__.py      66      0   100%
mocket/plugins/httpretty/core.py           2      0   100%
mocket/plugins/pook_mock_engine.py        47     45     4%   5-76
mocket/utils.py                           26      0   100%
--------------------------------------------------------------------
TOTAL                                    807     59    93%

=============================== 155 passed, 1 xpassed, 3 warnings in 10.85s ===============================

(.venv) ~/r/python-mocket (master|✔) $ pip freeze | grep aiohttp
aiohttp==3.8.6

@mindflayer
Copy link
Owner

mindflayer commented Oct 20, 2023

A possible culprit could be aio-libs/aiohttp#7336
Let me know if tests are passing with the rest of the Python versions >=3.8.

@oschwald
Copy link
Author

oschwald commented Oct 20, 2023 via email

@mindflayer
Copy link
Owner

mindflayer commented Oct 20, 2023

I am sorry I did not notice the version from your first message logs. I was focusing on the pipeline you linked.
If you manage to write down a snippet which fails that way, I'll definitely look into it.

@oschwald
Copy link
Author

I looked into this more, and it turns out there was a bug in our test suite where we were returning the text "null" on 204s. The new version of llhttp in aiohttp was stricter about this. I apologize for the noise. Thanks for taking a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants