diff --git a/aiohttp/streams.py b/aiohttp/streams.py index 7ac184391e6..82d404d617b 100644 --- a/aiohttp/streams.py +++ b/aiohttp/streams.py @@ -502,8 +502,9 @@ def _read_nowait_chunk(self, n: int) -> bytes: else: data = self._buffer.popleft() - self._size -= len(data) - self._cursor += len(data) + data_len = len(data) + self._size -= data_len + self._cursor += data_len chunk_splits = self._http_chunk_splits # Prevent memory leak: drop useless chunk splits