Skip to content

fix: assert the timeout class RSC19e's budgets can actually produce - #721

Merged
owenpearson merged 1 commit into
mainfrom
test/fix-rsc19e-timeout-assertion
Sep 29, 2026
Merged

owenpearson merged 1 commit into
mainfrom
test/fix-rsc19e-timeout-assertion

Conversation

@owenpearson

Copy link
Copy Markdown
Member

test/ably/rest/restrequest_test.py::TestRestRequest::test_timeout fails
intermittently in CI with httpx.ConnectTimeout, most recently on check (3.13)
for #703.

The test sets http_request_timeout=0.000001 and leaves http_open_timeout at its
default of 4. Http.make_request passes the pair through as an httpx 2-tuple,
which httpx reads as Timeout(connect=4, read=1e-06), so the request carries two
budgets and whichever expires first decides the exception class:

network outcome
host opens promptly the 1 µs read budget expires — ReadTimeout
host is slow to open the 4 s connect budget expires — ConnectTimeout

AblyRest(token="foo") resolves to three hosts (main.realtime.ably.net plus two
fallbacks) and make_request only re-raises on the last, so the runner has to
complete three connects before the assertion is reached — three chances for a slow
DNS or TLS path to be the first budget to go.

TimeoutException is the common base of the two, so the assertion still holds the
specification's point — that http_request_timeout is honoured — without depending
on how fast the runner reaches the host. resthttp_test.py:55 already asserts
TimeoutException for the same reason.

Verification

Both timeout paths were exercised against the assertion, forcing the second by
pointing the host list at an unroutable address:

reachable hosts : assertion PASS;  concrete class raised = ReadTimeout
black-holed host: assertion PASS;  concrete class raised = ConnectTimeout

The old assertion fails the second case. test_timeout passes in both its async and
its generated sync form, and ruff check . is clean.

🤖 Generated with Claude Code

`http_request_timeout` reaches httpx alongside the four-second default
`http_open_timeout`, so a request carries a connect budget as well as a read
budget and either can be the one to expire: a connection that opens promptly
exhausts the read budget, while a slow one exhausts the connect budget first.
Pinning the assertion to `ReadTimeout` makes the test a function of how quickly
the runner reaches the host, and `check (3.13)` has already failed on it with
`httpx.ConnectTimeout`.

`TimeoutException` is the common base of the two, and is what
`resthttp_test.py` already asserts for the same reason.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 42 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 0a069815-57ad-44ff-bfee-03280d07fdba

📥 Commits

Reviewing files that changed from the base of the PR and between 40e7419 and 0db006a.

📒 Files selected for processing (1)
  • test/ably/rest/restrequest_test.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ttypic ttypic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@owenpearson
owenpearson merged commit 2d583bf into main Sep 29, 2026
10 checks passed
@owenpearson
owenpearson deleted the test/fix-rsc19e-timeout-assertion branch September 29, 2026 12:33

This branch was successfully deployed

1 active deployment
staging/pull/721/features — 0db006ab Deployed Sep 29, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants