Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A raw built-in TimeoutError / socket.timeout is being let through in rare cases #9952

Open
1 task done
jogc opened this issue Nov 18, 2024 · 1 comment
Open
1 task done
Labels
bug needs-info Issue is lacking sufficient information and will be closed if not provided

Comments

@jogc
Copy link

jogc commented Nov 18, 2024

Describe the bug

A raw Python built-in TimeoutError / socket.timeout is let through in rare cases instead of an aiohttp.ClientError being generated. I would expect it being enough to handle aiohttp.ClientError to write robust code. It happens when socket.recv raises TimeoutError (or socket.timeout in older Python versions) due to recv syscall returning ETIMEDOUT. I'm not able to reproduce it but what I think happened in my case was that the connection was successfully established and right after the machine lost internet connectivity before/during the HTTP request headers being sent which causes Linux to timeout waiting for TCP ACK for the sent data.

This occurred on Python 3.7.3 / aiohttp 3.7.4.post0 but it seems aiohttp 3.8.5 on Python 3.11.2 also doesn't handle TimeoutError. I am not able to test on the latest version(s) sorry.

To Reproduce

Modify /usr/lib/python3.7/asyncio/selector_events.py by inserting a raise TimeoutError before every instance of recv being called.

Expected behavior

I expected an aiohttp.ClientOSError to be raised and since I handle aiohttp.ClientError that would have been enough.

Logs/tracebacks

python3[4494]: ERROR:asyncio:Fatal read error on socket transport
python3[4494]: protocol: <RequestHandler connected>
python3[4494]: transport: <_SelectorSocketTransport fd=10 read=polling write=<idle, bufsize=0>>
python3[4494]: Traceback (most recent call last):
python3[4494]:   File "/usr/lib/python3.7/asyncio/selector_events.py", line 801, in _read_ready__data_received
python3[4494]:     data = self._sock.recv(self.max_size)
python3[4494]: TimeoutError: [Errno 110] Connection timed out

Python Version

3.7.3

aiohttp Version

3.7.4.post0

multidict Version

5.1.0

propcache Version

WARNING: Package(s) not found: propcache

yarl Version

1.6.3

OS

Raspbian GNU/Linux

Related component

Client

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@jogc jogc added the bug label Nov 18, 2024
@Dreamsorcerer
Copy link
Member

We're not about to provide updates or try to figure out what is happening from 3 major versions ago. The description is fairly vague, but there's a good chance the issue no longer exists in 3.11. You'll need to test against the current version.

@Dreamsorcerer Dreamsorcerer added the needs-info Issue is lacking sufficient information and will be closed if not provided label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-info Issue is lacking sufficient information and will be closed if not provided
Projects
None yet
Development

No branches or pull requests

2 participants