Problem Description
I sometimes notice that web pages loaded with HTTP/2 in my browser sometimes stop loading images. I am trying to narrow this issue down. My first suspicion is the code in server.py as in #5034 we already noticed that exceptions are silently ignored in certain tasks.
I wrapped all tasks in try-except to see if there are any exceptions that cause tasks to die that was not expected. I found this:
[2022-02-26 20:56:41] 192.168.2.63:60214: Traceback (most recent call last):
[2022-02-26 20:56:41] File "/home/enduser/mitmproxy/mitmproxy/proxy/server.py", line 266, in handle_connection
[2022-02-26 20:56:41] await self.drain_writers()
[2022-02-26 20:56:41] File "/home/enduser/mitmproxy/mitmproxy/proxy/server.py", line 308, in drain_writers
[2022-02-26 20:56:41] await transport.writer.drain()
[2022-02-26 20:56:41] File "/usr/lib64/python3.9/asyncio/streams.py", line 387, in drain
[2022-02-26 20:56:41] await self._protocol._drain_helper()
[2022-02-26 20:56:41] File "/usr/lib64/python3.9/asyncio/streams.py", line 194, in _drain_helper
[2022-02-26 20:56:41] assert waiter is None or waiter.cancelled()
[2022-02-26 20:56:41] AssertionError
This assertion comes from within the asyncio code. Any idea what test could be done in drain_writers for each writer in order to not trigger the assertion? I am now running a modified version of drain_writers that looks like this:
for transport in self.transports.values():
if transport.writer is not None:
try:
await transport.writer.drain()
except OSError as e:
if transport.handler is not None:
asyncio_utils.cancel_task(transport.handler, f"Error sending data: {e}")
except AssertionError:
pass
Ugly but I will run this for a while to see if that is the reason for my missing images.
Problem Description
I sometimes notice that web pages loaded with HTTP/2 in my browser sometimes stop loading images. I am trying to narrow this issue down. My first suspicion is the code in server.py as in #5034 we already noticed that exceptions are silently ignored in certain tasks.
I wrapped all tasks in try-except to see if there are any exceptions that cause tasks to die that was not expected. I found this:
This assertion comes from within the
asynciocode. Any idea what test could be done indrain_writersfor each writer in order to not trigger the assertion? I am now running a modified version ofdrain_writersthat looks like this:Ugly but I will run this for a while to see if that is the reason for my missing images.