Skip to content

Apply the request timeout to the server lookup - #1569

Merged
frenck merged 1 commit into
mainfrom
frenck/dns-timeout
Oct 1, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/dns-timeout

Conversation

@frenck

@frenck frenck commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Breaking change

None. request_timeout now covers the server lookup and the HTTP request together, instead of only the HTTP request. The lookup only happens on the first request and after a failure, since the server is cached in between.

Proposed change

Found in a review of the library. The DNS SRV lookup that picks an API server ran before the asyncio.timeout block in _request_once(), so request_timeout did not apply to it. With a DNS server that does not answer, a request waited on the resolver's own timeouts instead, and did so again on every one of the five attempts. Reproduced: a lookup of 0.3 seconds succeeded with a request_timeout of 0.01 seconds.

The lookup now runs inside the same timeout as the request. A lookup that runs out of time is handled like any other slow request: the client raises a RadioBrowserConnectionTimeoutError and retries.

The new test uses a lookup that never answers; it hangs forever without this change.

Type of change

  • Dependency or tooling upgrade
  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Deprecation (replaces or removes a feature, with a migration path)
  • Breaking change (a fix or feature that changes existing behavior)
  • Code quality, refactor, or test-only change
  • Documentation only

Additional information

  • This PR fixes or closes issue: fixes # None
  • This PR is related to: None
  • Link to a separate documentation pull request: None

Checklist

  • I fully understand the code in this pull request and can explain every line, including any AI-assisted changes.
  • The change is covered by tests, and poetry run pytest passes locally. A pull request cannot be merged unless CI is green.
  • poetry run prek run --all-files passes (lint, format, and type checks).
  • No commented-out or dead code is left in the pull request.

The DNS SRV lookup for the API server ran before the request timeout
started, so a DNS server that did not answer could stall a request far
beyond request_timeout, on every retry. Look up the server inside the same
timeout, so it is handled and retried like any other slow request.
@frenck frenck added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Oct 1, 2026
@frenck
frenck merged commit c101e2a into main Oct 1, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant