Skip to content

test: wait out fresh endpoints in the http and proxy-proto tests - #171

Merged
wesnel merged 2 commits into
mainfrom
wgn/test-fresh-endpoint-flake
Nov 17, 2026
Merged

wesnel merged 2 commits into
mainfrom
wgn/test-fresh-endpoint-flake

Conversation

@wesnel

@wesnel wesnel commented Nov 16, 2026

Copy link
Copy Markdown
Member

test_http_listener and test_proxy_proto failed 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:

  • An http-scheme endpoint answered its http:// URL with a 307 to https:// on the same host, for about 0.6 s (1 of 20). retry_request followed the redirect and retried the https URL, where nothing answers an http-scheme listener, so test_http_listener got only 404s until its retries ran out.
  • A proxy-proto endpoint answered 404 ERR_NGROK_3200 (2 of 20). test_proxy_proto sends a single request, so its handler never saw the PROXY header.

tls_passthrough_request already waited out the 404 for the tls listener tests. Its loop is now get_when_online, which also retries the redirect to https on the same host and doesn't 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.

The AGENT-1371 reconnect pull requests (#169, #170) stack on this one.

Validation

  • Before the fix, the new get_when_online test for the redirect failed with 200 != 307. With get_when_online following redirects, the two redirect tests fail.
  • Against ngrok, test_http_listener and test_proxy_proto ran 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 in validate_http_request, after forwarding started, as it now sits in test_http_listener; test_proxy_proto is the same.

Weak spots, assumptions and decisions

  • Assumption: the edge's 307 to https on the same host means the http-scheme endpoint isn't routable yet. If an endpoint under test ever redirects to its own https URL on purpose, get_when_online retries it for 10 s and then returns the 307.
  • Decision: test_http_listener waits first and keeps retry_request for the request it checks. The alternatives were waiting in validate_http_request, which every online test shares, or replacing retry_request, which retries 5xx and 429 answers that get_when_online returns at once.
  • Other online tests that send one request to a fresh endpoint (such as the ip-restriction ones) are unchanged; this failure wasn't seen in them.

Reverting

A two-way door: only tests change. Reverting brings back the intermittent failures of these two tests.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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
wesnel added this pull request to stack #172 November 16, 2026 22:51
@wesnel
wesnel marked this pull request as ready for review November 16, 2026 22:51
@wesnel
wesnel merged commit 4777e21 into main Nov 17, 2026
17 checks passed
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.

3 participants