Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(site/e2e): close mock external-auth servers in teardown - #26575

#26575
Merged
jakehwll merged 5 commits into
maincoder/coder:mainfrom
jakehwll/devex-413-flake-e2e-externalauthspectscoder/coder:jakehwll/devex-413-flake-e2e-externalauthspectsCopy head branch name to clipboard
Jul 1, 2026
Merged

fix(site/e2e): close mock external-auth servers in teardown#26575
jakehwll merged 5 commits into
maincoder/coder:mainfrom
jakehwll/devex-413-flake-e2e-externalauthspectscoder/coder:jakehwll/devex-413-flake-e2e-externalauthspectsCopy head branch name to clipboard

Conversation

@jakehwll

@jakehwll jakehwll commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

🤖 This PR was written by Coder Agents on behalf of Jake Howell.

Stack:

  1. fix(site/e2e): close mock external-auth servers in teardown #26575 fix(site/e2e): close mock external-auth servers in teardown ← this PR
  2. fix(site/e2e): accept 404 from external auth reset hook #26793 fix(site/e2e): accept 404 from external auth reset hook
  3. fix(site/src): refresh provider state after device-flow exchange #26795 fix(site/src): refresh provider state after device-flow exchange
  4. fix(site/e2e): reset both providers in external auth hook #26798 fix(site/e2e): reset both providers in external auth hook
  5. chore(site/e2e): re-enable externalAuth suite #26648 chore(site/e2e): re-enable externalAuth suite

The externalAuth e2e suite has been skipped since #17235 because createServer in site/e2e/helpers.ts started an express server but never gave callers a way to close it. On retries or repeated runs, the listener from the previous invocation was still bound to the hardcoded port and the next beforeAll failed with EADDRINUSE, eventually timing out in waitForPort.

createServer now returns a { app, close } pair. The web flow closes in afterAll; the device flow uses try/finally. closeAllConnections() is called before close() so teardown stays bounded if keep-alive connections linger.

The suite remains test.describe.skip here; #26648 flips the skip off once the rest of the stack is in.

Refs https://linear.app/codercom/issue/DEVEX-413
Refs coder/internal#356

Decision log

Discussed the full options list with @jakehwll before drafting. Picked option A (minimal teardown) because:

Returning close rather than the raw http.Server encapsulates the closeAllConnections + close choreography so callers don't repeat it. closeAllConnections is optional-chained because it landed in Node 18.2; coder/coder runs newer, but the chain costs nothing.

The device test uses try/finally rather than a shared afterEach to keep per-test state local. The web flow's afterAll mirrors its beforeAll.

createServer now returns a close handle so callers can release the listener after the test. The web flow closes in afterAll; the device flow uses try/finally. This prevents leaked listeners from triggering EADDRINUSE on the next run, the long-standing root cause of the externalAuth.spec.ts flake (coder/internal#356).
@linear-code

linear-code Bot commented Jun 22, 2026

Copy link
Copy Markdown

DEVEX-413

@datadog-coder

This comment has been minimized.

@jakehwll

jakehwll commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Comment posted by Coder Agents on behalf of Jake Howell.

Layer 1 stress proof, side-by-side, same harness, same port, both code paths pasted verbatim from the respective site/e2e/helpers.ts:

Run 1: main only, 100 iterations on port 50516

main   (no close handle)  FAIL at iteration 2 (EADDRINUSE: listen EADDRINUSE: address already in use 0.0.0.0:50516) elapsed=6ms

Run 2: jakehwll/devex-413-flake-e2e-externalauthspects only, 100 iterations on port 50516

branch (close handle)     OK (100/100)                                                 elapsed=11ms

Run 3: jakehwll/devex-413-flake-e2e-externalauthspects only, 10,000 iterations on port 50516

branch (close handle)     OK (10000/10000)                                             elapsed=284ms

@jakehwll
jakehwll marked this pull request as ready for review June 24, 2026 03:09

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 863cce9910

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/e2e/helpers.ts Outdated
Reorders the teardown sequence so server.close() runs first, then server.closeAllConnections(). The previous order let a connection accepted between the two calls escape the force-close, keeping close() pending until the keep-alive timeout. Addresses review on #26575.
Comment thread site/e2e/helpers.ts Outdated
Comment thread site/e2e/helpers.ts Outdated
@jakehwll
jakehwll merged commit b341ce6 into main Jul 1, 2026
34 of 35 checks passed
@jakehwll
jakehwll deleted the jakehwll/devex-413-flake-e2e-externalauthspects branch July 1, 2026 03:14
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.