Skip to content

verifier_tools/verify: Increase httpClient timeout for large binary i… - #31

Merged
billy-lau merged 1 commit into
android:mainfrom
billy-lau:verifier/http-timeout
Sep 23, 2026
Merged

billy-lau merged 1 commit into
android:mainfrom
billy-lau:verifier/http-timeout

Conversation

@billy-lau

Copy link
Copy Markdown
Member

…nfo downloads

Previously, httpClient in internal/tiles/reader.go had a flat 30-second Timeout, which in net/http bounds the entire request lifecycle including reading the full response body (io.ReadAll(resp.Body)). Fetching the ~210 MB package_info.txt for google_1p_apk (2026/01) required ~56 Mbps of sustained throughput and failed with context deadline exceeded on slower or shared connections.

Separate connection/header timeouts from the total body-read timeout:

  1. Configure http.Transport with DialContext (10s timeout), ForceAttemptHTTP2: true (to preserve HTTP/2 multiplexing with a custom dialer), TLSHandshakeTimeout (10s), and ResponseHeaderTimeout (30s) so unreachable or unresponsive servers still time out within 30 seconds.
  2. Increase httpClient.Timeout to 5 minutes (defaultHTTPTimeout) to allow large legacy binary info files to finish streaming.
  3. Wrap http.NewRequestWithContext and httpClient.Do errors with %w in readFromURLContext to preserve timeout/cancellation error chains.

Test:

  • cd verifier_tools/verify && go test -race -v ./...
  • Added TestHTTPClientTimeoutConfiguration and TestReadFromURLContextStreamingAndCancellation in internal/tiles/reader_test.go.

Change-Id: Ia17354f130b28880ef75117b98c42581fa8a89f8

…nfo downloads

Previously, `httpClient` in `internal/tiles/reader.go` had a flat 30-second
`Timeout`, which in `net/http` bounds the entire request lifecycle
including reading the full response body (`io.ReadAll(resp.Body)`).
Fetching the ~210 MB `package_info.txt` for `google_1p_apk (2026/01)`
required ~56 Mbps of sustained throughput and failed with `context deadline
exceeded` on slower or shared connections.

Separate connection/header timeouts from the total body-read timeout:
1. Configure `http.Transport` with `DialContext` (`10s` timeout),
   `ForceAttemptHTTP2: true` (to preserve HTTP/2 multiplexing with a custom
   dialer), `TLSHandshakeTimeout` (`10s`), and `ResponseHeaderTimeout`
   (`30s`) so unreachable or unresponsive servers still time out within
   30 seconds.
2. Increase `httpClient.Timeout` to 5 minutes (`defaultHTTPTimeout`) to
   allow large legacy binary info files to finish streaming.
3. Wrap `http.NewRequestWithContext` and `httpClient.Do` errors with `%w`
   in `readFromURLContext` to preserve timeout/cancellation error chains.

Test:
- `cd verifier_tools/verify && go test -race -v ./...`
- Added `TestHTTPClientTimeoutConfiguration` and
  `TestReadFromURLContextStreamingAndCancellation` in
  `internal/tiles/reader_test.go`.

Change-Id: Ia17354f130b28880ef75117b98c42581fa8a89f8
@billy-lau
billy-lau merged commit 19ebe00 into android:main Sep 23, 2026
7 checks passed
@billy-lau
billy-lau deleted the verifier/http-timeout branch September 23, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant