[Python] "Connection broken: IncompleteRead(50454677 bytes read, 35845891 more expected)" upon...

Discussão em 'Python' iniciado por Stack, Abril 26, 2025.

  1. Stack

    Stack Membro Participativo

    Upon fecthing a large collection item from Postman's API I get the following error:


    RuntimeError: Chunked transfer error: ('Connection broken: IncompleteRead(50454677 bytes read, 35845891 more expected)', IncompleteRead(50454677 bytes read, 35845891 more expected))
    ​

    the stack trace is very long. This is are relevant exceptions being raised


    /home/dropout/.cache/pypoetry/virtualenvs/python-postman-sdk-zfuq-kzi-py3.10/lib/python3.10/site-packages/urllib3/response.py:883 in _raw_read │ │
    │ │ 880 │ │ │ │ │ # addressing it here to make sure IncompleteRead is
    │ │ 881 │ │ │ │ │ # raised during streaming, so all calls with incorrect
    │ │ 882 │ │ │ │ │ # Content-Length are caught.
    │ │ ❱ 883 │ │ │ │ │ raise IncompleteRead(self._fp_bytes_read, self.length_remaining)

    241 │ │ except requests.exceptions.ChunkedEncodingError as e:
    │ │ ❱ 242 │ │ │ raise RuntimeError(f"Chunked transfer error: {e}")
    ​

    Originally, we were not handling retries in our implementation. But after adding retries and a higher timeout for connection and reading, the problem persists.

    There have been a few ocassions in which the response has been received and the output displayed gracefully. But the majority of tries end up in this error.

    This leads me to believe that it is either a connection stability issue, or something up Postman's end.

    The project is being handled and outputed through a Typer CLI and uses requests and urlib3. Let me know if you need a snippet of the involved method.

    Does anybody in here know how can fix this so it receives full contents in a resilient way?

    Continue reading...

Compartilhe esta Página