Open
Description
Hello. As reported here:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087334
while building the Debian package for vcr.py version 7.0.0 on AWS virtual machines of type m7a.medium or r7a.medium, I get the following error:
E BrokenPipeError: [Errno 32] Broken pipe
Complete error message here:
Incidentally, those AWS instances have 1 CPU, but we don't know if that's relevant or not (it may be the case that it fails because they are "too slow").
An error like this one started to happen simultaneously on packages vcr.py and pytest-httpbin, so we suspected of the common build-dependency python3-urllib3.
Now pytest-httpbin does not fail anymore but vcr.py still fails, so maybe there is indeed a problem in vcr.py.
Thanks.
Metadata
Metadata
Assignees
Labels
No labels
Activity
cjwatson commentedon Jan 28, 2025
I spent some time investigating this today. It's possible I'm missing something, but this seems to be a complex interaction of several different problems.
I'm seeing failures in
tests/integration/test_urllib3.py::test_post
(which has been around for a while) andtests/unit/test_stubs.py::TestVCRConnection::test_body_consumed_once_*
(which were introduced in #851). In all cases, the error is essentiallyBrokenPipeError
because thehttpbin
test server is closing the connection before the test has finished sending the request body. (This is likely to be somewhat racy, which is why we're only seeing this in certain circumstances.)strace
reveals thathttpbin
is closing the connection with a response along these lines (I've decoded it from the rawsendto
calls for readability):The relevant code is httpbin.core.before_request, which denies chunked requests unless it's running under gunicorn, to work around various bugs. It's thus hard to see how VCR.py can test chunked transfer requests using
pytest-httpbin
without some work elsewhere.I tried hacking
httpbin.core.before_request
locally to runrequest.environ["wsgi.input_terminated"] = 1
instead of aborting, and the tests hung. I guess that's a relative of theflask
problem mentioned in that comment inhttpbin
, but I wasn't able to track down the details.While debugging this, I also found that the
test_body_consumed_once_*
unit tests are broken in a different way: because they don't send aContent-Type
header,werkzeug
doesn't bother to read the request body (I think). The simplest change there is probably to addheaders={"Content-Type": "application/x-www-form-urlencoded"}
to therequest
calls in_test_body_consumed_once
and change the body iterators in the test methods from1234567890
toa=1234567890
(and similar). I wasn't able to fully test this fix due to the problems above, though.I don't know how to get much further here, because trying to test chunked requests using
pytest-httpbin
just seems kind of doomed at the moment. I also don't think this is really a new issue: kevin1024/pytest-httpbin#33 and (probably) kevin1024/pytest-httpbin#59 seem to be more or less the same thing.