Repository navigation
test: wait out fresh endpoints in the http and proxy-proto tests - #171
Merged
Merged
Conversation
Other online tests send a single request to a fresh endpoint and fail when the edge answers before the endpoint is routable. get_when_online holds the retry for that answer so they can use it too; tls_passthrough_request keeps its behaviour, returning the SSLError that ends the retries.
test_http_listener and test_proxy_proto failed intermittently when their first request reached ngrok's edge before the fresh endpoint was routable. Measured with 20 fresh endpoints of each kind: - An http-scheme endpoint answered its http URL with a 307 to https on the same host (1 of 20, for about 0.6 s). retry_request followed the redirect and retried the https URL, where no endpoint answers an http-scheme listener, so test_http_listener got only 404s for 30 s. - A proxy-proto endpoint answered 404 ERR_NGROK_3200 (2 of 20), and test_proxy_proto sends a single request, so its handler never saw the PROXY header. get_when_online now also retries that redirect, and does not follow redirects itself. test_http_listener waits with it once forwarding has started, before validate_http_request's own request, and test_proxy_proto requests through it. Other online tests are unchanged.
wesnel
force-pushed
the
wgn/test-fresh-endpoint-flake
branch
from
November 16, 2026 19:45
11f63e4 to
9cbd0bc
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the test-only endpoint-readiness changes.
No open issues 🎉
What changed in this PR
Stabilizes the HTTP and PROXY-protocol integration tests by waiting for fresh ngrok endpoints to become routable. Only test code changes.
Changes:
- Extracts shared readiness polling that retries offline responses and same-host HTTP-to-HTTPS redirects without following redirects.
- Applies polling to the HTTP and PROXY-protocol tests while preserving final HTTP validation and TLS passthrough error handling.
- Adds regression tests for redirect handling and requests reaching the PROXY-protocol backend.
| File | Description |
|---|---|
test/test.py |
Adds shared readiness polling, reuses it for TLS passthrough, and updates the HTTP and PROXY-protocol tests. |
test/test_tls_passthrough.py |
Extends the fake edge and adds tests for readiness retries and redirect behavior. |
Review effort: Balanced
wesnel
marked this pull request as ready for review
November 16, 2026 22:51
wesnel
requested review from
andrew-harris-at-ngrok,
grant-higgins-0,
joshbottelberghe,
kevin-ngrok and
sajethm
November 16, 2026 22:53
joshbottelberghe
approved these changes
Nov 16, 2026
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.
test_http_listenerandtest_proxy_protofailed intermittently when their first request reached ngrok's edge before the fresh endpoint was routable. Measured on 20 fresh endpoints of each kind, with the first answers recorded without following redirects:http://URL with a 307 tohttps://on the same host, for about 0.6 s (1 of 20).retry_requestfollowed the redirect and retried the https URL, where nothing answers an http-scheme listener, sotest_http_listenergot only 404s until its retries ran out.404 ERR_NGROK_3200(2 of 20).test_proxy_protosends a single request, so its handler never saw the PROXY header.tls_passthrough_requestalready waited out the 404 for the tls listener tests. Its loop is nowget_when_online, which also retries the redirect to https on the same host and doesn't follow redirects itself.test_http_listenerwaits with it once forwarding has started, beforevalidate_http_request's own request, andtest_proxy_protorequests through it. Other online tests are unchanged.The AGENT-1371 reconnect pull requests (#169, #170) stack on this one.
Validation
get_when_onlinetest for the redirect failed with200 != 307. Withget_when_onlinefollowing redirects, the two redirect tests fail.test_http_listenerandtest_proxy_protoran 30 times each with the fix, and none of the 60 runs failed. At the measured rates the unfixed tests would have failed about 4 or 5 times. In that run the wait sat invalidate_http_request, after forwarding started, as it now sits intest_http_listener;test_proxy_protois the same.Weak spots, assumptions and decisions
get_when_onlineretries it for 10 s and then returns the 307.test_http_listenerwaits first and keepsretry_requestfor the request it checks. The alternatives were waiting invalidate_http_request, which every online test shares, or replacingretry_request, which retries 5xx and 429 answers thatget_when_onlinereturns at once.Reverting
A two-way door: only tests change. Reverting brings back the intermittent failures of these two tests.