Fix DownloadManager hanging on stalled connections#98
Merged
ThomasFarstrike merged 1 commit intoMar 30, 2026
Merged
Conversation
The HTTP connection (session.get) had no timeout, only individual chunk reads did. If the TCP connection or TLS handshake stalled, the entire async balance fetch loop would hang forever. This was observed on ESP32 devices where intermittent WiFi issues caused session.get() to never return, freezing the wallet UI on "Connecting to backend". Uses the existing _CHUNK_TIMEOUT_SECONDS (10s) for the connection timeout. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
6ca8783 to
81a907c
Compare
Contributor
|
Splendit! |
bitcoin3us
pushed a commit
to bitcoin3us/MicroPythonOS
that referenced
this pull request
Mar 31, 2026
The desktop aiohttp implementation doesn't support the timeout keyword argument added in MicroPythonOS#98. Fall back to calling session.get() without timeout when TypeError is raised, so downloads work on both ESP32 (with timeout) and desktop (without). Fixes test_custom_headers and test_json_download failures on desktop builds. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2 tasks
bitcoin3us
pushed a commit
to bitcoin3us/MicroPythonOS
that referenced
this pull request
Mar 31, 2026
The MicroPython aiohttp library had no timeout support (marked as TODO). Add a timeout parameter to request_raw(), _request(), and request() that wraps asyncio.open_connection() with asyncio.wait_for(). This allows DownloadManager to use session.get(timeout=...) to prevent connections from hanging indefinitely on stalled TCP/TLS handshakes, which was the original fix in MicroPythonOS#98. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
ThomasFarstrike
pushed a commit
that referenced
this pull request
Mar 31, 2026
…107) * Fix DownloadManager timeout kwarg compatibility with desktop aiohttp The desktop aiohttp implementation doesn't support the timeout keyword argument added in #98. Fall back to calling session.get() without timeout when TypeError is raised, so downloads work on both ESP32 (with timeout) and desktop (without). Fixes test_custom_headers and test_json_download failures on desktop builds. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * Add connection timeout support to aiohttp and restore in DownloadManager The MicroPython aiohttp library had no timeout support (marked as TODO). Add a timeout parameter to request_raw(), _request(), and request() that wraps asyncio.open_connection() with asyncio.wait_for(). This allows DownloadManager to use session.get(timeout=...) to prevent connections from hanging indefinitely on stalled TCP/TLS handshakes, which was the original fix in #98. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --------- Co-authored-by: Richard Taylor <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
session.get()inDownloadManager._download_url_async()_CHUNK_TIMEOUT_SECONDS), but the initial TCP/TLS connection had noneRoot cause
session.get(url, headers=headers)at line 118 ofdownload_manager.pyhad no timeout parameter. If the TLS handshake or TCP connection stalled, thisawaitwould never return, blocking the calling coroutine permanently.Fix
Pass the existing
_CHUNK_TIMEOUT_SECONDS(10s) as the timeout forsession.get(), so stalled connections fail gracefully and the caller's retry logic can recover.Test plan
🤖 Generated with Claude Code