Skip to content

Commit

Permalink
Fix: aiohttp assert exception on connection lost (#406)
Browse files Browse the repository at this point in the history
Problem: a bug in aiohttp causes an assertion error to appear in
the logs whenever an HTTP connection is lost.

Solution: there is no mainline fix in aiohttp. It is not trivial
to install a forked version of aiohttp, so the simplest solution
for now is to apply the aiohttp patch directly.

Bumped aiohttp to 3.8.4 at the same time.
  • Loading branch information
odesenfans authored Apr 24, 2023
1 parent c0047b2 commit 54b3f23
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions deployment/docker-build/aiohttp.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/aiohttp/web_protocol.py b/aiohttp/web_protocol.py
index 10a96080..f103b167 100644
--- a/aiohttp/web_protocol.py
+++ b/aiohttp/web_protocol.py
@@ -299,6 +299,8 @@ class RequestHandler(BaseProtocol):
exc = ConnectionResetError("Connection lost")
self._current_request._cancel(exc)

+ if self._task_handler is not None:
+ self._task_handler.cancel()
if self._waiter is not None:
self._waiter.cancel()

2 changes: 2 additions & 0 deletions deployment/docker-build/pyaleph.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ COPY deployment/scripts ./deployment/scripts
COPY .git ./.git
COPY src ./src
RUN pip install -e .
COPY deployment/docker-build/aiohttp.diff /tmp/aiohttp.diff
RUN patch /opt/venv/lib/python3.11/site-packages/aiohttp/web_protocol.py /tmp/aiohttp.diff


FROM base
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ install_requires =
aiocache==0.11.1
aiohttp-cors==0.7.0
aiohttp-jinja2==1.5
aiohttp==3.8.3
aiohttp==3.8.4
aioipfs@git+https://github.com/aleph-im/aioipfs.git@d671c79b2871bb4d6c8877ba1e7f3ffbe7d20b71
alembic==1.8.1
aleph-message==0.3.2
Expand Down

0 comments on commit 54b3f23

Please sign in to comment.