Skip to content

test: (flake) isolate certificate failure in bad TLS dial - #611

Open
Emyrk wants to merge 1 commit into
coder:masterfrom
Emyrk:test-isolate-bad-tls
Open

Emyrk wants to merge 1 commit into
coder:masterfrom
Emyrk:test-isolate-bad-tls

Conversation

@Emyrk

@Emyrk Emyrk commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

The bad TLS dial test could pass on any network error and leave an idle HTTP connection alive when the package checked for goroutine leaks, as seen in #610.

In a local reproduction, dialing wss://totallyfake.nhooyr.io returned failed to WebSocket dial: expected handshake response status code 101 but got 200. TLS had succeeded. The server did not upgrade the connection, so Dial returned a nil WebSocket connection. The HTTP transport kept the underlying connection idle for reuse, and its read and write goroutines were still running at test shutdown. CI logged the goroutine stacks, not the HTTP status.

  • Dial a local TLS server and require x509.UnknownAuthorityError. The client now rejects the certificate during the TLS handshake, before an HTTP connection can enter the idle pool.
  • Leave production dialing and the package leak check unchanged.
Reproduction and verification

On master (12c866f), running only TestBadDials/badReq/badTLS reproduced the two net/http persistent connection goroutines. With this change, the same subtest passed in 25 fresh race-enabled processes on each of Go 1.26.11 and 1.27.4. The full ordinary and race suites passed on both. This fixes the test fixture rather than adding a grace period to TestMain as proposed in #603.

Coder Agents on behalf of @Emyrk.

An external hostname can leave HTTP transport goroutines alive at the package leak check and can fail before certificate verification. Dial a local TLS test server and require an untrusted certificate instead.
@Emyrk

Emyrk commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

I don't know what the goal of the original test was. This does change the test semantics

@Emyrk
Emyrk marked this pull request as ready for review December 4, 2026 16:32
@Emyrk Emyrk changed the title test: isolate certificate failure in bad TLS dial test: (flake) isolate certificate failure in bad TLS dial Dec 4, 2026

This branch has not been deployed

No deployments
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.

2 participants