Skip to content

Commit

Permalink
🐛 Fix OverwhelmedTraffic error with conn that receive GoAway event af…
Browse files Browse the repository at this point in the history
…ter an idle period
  • Loading branch information
Ousret committed Dec 6, 2024
1 parent 42b0dc7 commit 0f1272e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
2.12.902 (2024-12-05)
2.12.902 (2024-12-06)
=====================

- Fixed a rare issue where Happy-Eyeballs algorithm would not respect timeout for a plain HTTP connection where all available endpoints are unreachable.
- Fixed an issue where a HTTP/2 idle connection would be considered "used/saturated" instead of "idle" when remote expressed wish to goaway.
This issue can lead to a ``traffic_police.OverwhelmedTraffic`` in synchronous context and indefinite hang in asynchronous after awhile.
- Increased default keepalive window to 1h by default for HTTP/2, and HTTP/3.

2.12.901 (2024-12-04)
=====================
Expand Down
2 changes: 1 addition & 1 deletion src/urllib3/_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,6 @@ def __new__(
DEFAULT_BACKGROUND_WATCH_WINDOW: float = 5.0
MINIMAL_BACKGROUND_WATCH_WINDOW: float = 0.05

DEFAULT_KEEPALIVE_DELAY: float = 300.0
DEFAULT_KEEPALIVE_DELAY: float = 3600.0
DEFAULT_KEEPALIVE_IDLE_WINDOW: float = 60.0
MINIMAL_KEEPALIVE_IDLE_WINDOW: float = 1.0
6 changes: 5 additions & 1 deletion src/urllib3/backend/hface.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ def __init__(
def is_saturated(self) -> bool:
if self._protocol is None:
return True
return self._protocol.is_available() is False
# is_available also includes whether we must goaway
# we want to focus on stream capacity here.
if self._protocol.is_available() is False:
return self._protocol.has_expired() is False
return False

@property
def is_multiplexed(self) -> bool:
Expand Down
2 changes: 2 additions & 0 deletions src/urllib3/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ def is_closed(self) -> bool:
def is_connected(self) -> bool:
if self.sock is None:
return False
# has_expired can be True when the connection isn't dead
# with GoAway for example.
if self._promises or self._pending_responses:
return True
return self._protocol is not None and self._protocol.has_expired() is False
Expand Down

0 comments on commit 0f1272e

Please sign in to comment.