-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
π Describe the bug
A ClientPayloadError
: Response payload is not completed
exception is raised when reading the response of a GET request from the GitHub REST API (this should not be especially relevant). The response seems correct and using curl
succeeds all the time.
π‘ To Reproduce
Do lots of requests against an endpoint of the GitHub API (it happens from time to time).
π‘ Expected behavior
The response is correctly parsed.
π Logs/tracebacks
File "/opt/lib/python3.8/site-packages/gidgethub/aiohttp.py", line 20, in _request
return response.status, response.headers, await response.read()
File "/opt/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 973, in read
self._body = await self.content.read()
File "/opt/lib/python3.8/site-packages/aiohttp/streams.py", line 358, in read
block = await self.readany()
File "/opt/lib/python3.8/site-packages/aiohttp/streams.py", line 380, in readany
await self._wait('readany')
File "/opt/lib/python3.8/site-packages/aiohttp/streams.py", line 296, in _wait
await waiter
aiohttp.client_exceptions.ClientPayloadError: Response payload is not completed
Some contextual information at the time of the exception at aiohttp/streams.py", line 358, in read
:
blocks = [b'[\n {\n "id": 2941521,\n "node_id": "MDU6TGFiZWwyOTQxNTIx",\n "url": "https://REDACTED_GITHUB_URL/repos/testorg/test-debian/labels/skip-issue",\n "name": "skip-issue",\n "color": "000000",\n "default": false\n }\n]\n']
n=-1
As you can see the blocks contain the whole payload (the full JSON) but aiohttp
still complains about the payload not being completed.
π Your version of the Python
$ python --version
Python 3.8.1
π Your version of the aiohttp/yarl/multidict distributions
$ python -m pip show aiohttp
Name: aiohttp
Version: 3.6.2
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: Nikolay Kim
Author-email: [email protected]
License: Apache 2
Location: .../versions/3.8-dev/envs/medusa/lib/python3.8/site-packages
Requires: async-timeout, attrs, chardet, multidict, yarl
Required-by: raven-aiohttp, pytest-aiohttp, aiojobs
$ python -m pip show multidict
Name: multidict
Version: 4.7.3
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: .../versions/3.8-dev/envs/medusa/lib/python3.8/site-packages
Requires:
Required-by: yarl, aiohttp
$ python -m pip show yarl
Name: yarl
Version: 1.4.2
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: /Users/pgalindo3/.pyenv/versions/3.8-dev/envs/medusa/lib/python3.8/site-packages
Requires: idna, multidict
Required-by: aiohttp
π Additional context
I suspect this has to be with this comment:
Lines 352 to 356 in 1740c99
# TODO: should be `if` instead of `while` | |
# because waiter maybe triggered on chunk end, | |
# without feeding any data | |
while not self._buffer and not self._eof: | |
await self._wait('read') |
as this is where is failing and the situation seems that is the one described in the TODO
.