Jake Howell cfc66b5de3 fix: reset both providers in external auth hook (#26798)
> 🤖 This PR was written by Coder Agents on behalf of Jake Howell.

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

Surfaced by stress-testing the leaf state of the stack locally with
`--repeat-each=N`. The suite passes on iter 1, then deterministically
fails the device test on every subsequent iteration:

| iter | device | web | workspace |
|---|---|---|---|
| 1 | ✓ 2.8s | ✓ 2.5s | ✓ 6.2s |
| 2 | **✘ 30.1s** | ✓ 2.6s | ✓ 6.2s |
| 3 | **✘ 30.1s** | ✓ ~2.5s | ✓ ~6s |
| … | … | … | … |

`resetExternalAuthKey` in `site/e2e/hooks.ts` only deletes the link for
`gitAuth.webProvider`, never `gitAuth.deviceProvider`. So:

```ts
path: `/api/v2/external-auth/${gitAuth.webProvider}?coder_session_token=${sessionCookie?.value}`,
```

Iter 1 of the device test creates a link for the `device` provider
against the test user. The cleanup hook between tests resets `web` but
not `device`. On iter 2 the page hits `/external-auth/device`,
`externalAuthProviderQuery.data.authenticated` is already `true`, the
page renders the authorized state immediately, and the test's
`sentPending.wait()` hangs forever because the mock token endpoint is
never polled. The whole test times out at 30s.

Fix: reset every provider the suite exercises. Refactored the per-link
delete into a Promise-returning helper so errors actually propagate; the
previous `throw` inside the response and `error` callbacks crashed the
worker rather than rejecting the call.

Doesn't affect CI (single run per PR, fresh `--ephemeral` coderd), but
it makes the suite robust to local stress testing and to anyone
re-running it in the same coderd process. Filed before the un-skip lands
so the un-skipped suite is repeatable from day one.

Local verification: `pnpm playwright:test e2e/tests/externalAuth.spec.ts
--repeat-each=20 --workers=1` → 61/61 passing in 4m48s. Same command
before this fix → 1 pass, then deterministic device-test timeouts.

Refs https://linear.app/codercom/issue/DEVEX-413

<details>
<summary>Why a separate PR</summary>

This is the fourth distinct root cause that piled up while the suite was
skipped, and it's orthogonal to the other three. #26575 fixes the
listener leak, #26793 fixes the 404 hook contract drift, #26795 fixes
the dropped invalidation, and this PR fixes the per-test cleanup so the
suite is actually repeatable. #26648 then just flips `.skip`.

</details>
2026-08-24 23:12:52 +07:00
…
…

Coder Logo Light Coder Logo Dark

Self-Hosted Cloud Development Environments and AI Agents

Coder Banner Light Coder Banner Dark

Quickstart | Docs | Why Coder | Premium

discord release godoc OpenSSF Best Practices OpenSSF Scorecard license

Coder is a self-hosted platform for cloud development environments and AI coding agents. Workspaces are defined with Terraform, connected through a secure Wireguard® tunnel, and automatically shut down when not used. Coder Agents runs a native AI coding agent whose loop executes in the control plane on your infrastructure, with no API keys in workspaces.

  • Define cloud development environments in Terraform
    • EC2 VMs, Kubernetes Pods, Docker Containers, etc.
  • Automatically shutdown idle resources to save on costs
  • Onboard developers in seconds instead of days
  • Delegate coding work to AI agents on your infrastructure
    • Bring any model (Anthropic, OpenAI, Google, Bedrock, self-hosted)
    • No LLM credentials in workspaces, user identity on every action
    • Centralized model governance, cost tracking, and audit logging

Coder platform showing templates and a running workspace

Quickstart

Check out our install guides for other methods and a complete tutorial.

Try Coder with the install script on Linux and macOS, or grab the latest binary or installer from GitHub Releases on Windows:

curl -L https://coder.com/install.sh | sh

Start the server and open http://localhost:3000 to create your initial user, create a Docker template, and provision your first workspace:

coder server

For a production deployment, add a PostgreSQL database (version 13 or later) and an external access URL, and see our validated architectures for sizing and infrastructure guidance:

coder server --postgres-url <url> --access-url <url>

Without these flags, Coder uses a built-in database and sets up a *.try.coder.app access URL for evaluation. Use coder --help for the full list of flags and environment variables.

Documentation

Browse the documentation or visit a specific section below:

  • Workspaces: Workspaces contain the IDEs, dependencies, and configuration information needed for software development
  • Templates: Templates are written in Terraform and describe the infrastructure for workspaces
  • Coder Agents: Delegate coding work to AI agents running on your self-hosted infrastructure
  • AI Gateway: Centralize authentication, auditing, and cost controls for AI tooling
  • Administration: Learn how to operate Coder
  • Premium: Learn about paid features built for large teams
  • IDEs: Connect your existing editor to a workspace

Support

Open an issue for bugs and feature requests.

For community support, showcasing what you built, and feedback on in-progress features, join our Discord or GitHub Discussions.

Dedicated support is included in Coder Premium. For more information, visit coder.com/pricing.

Integrations

New integrations are always in progress. Open an issue to request one. Contributions are welcome in any official or community repository.

Official

Community

Contributing

New contributors are always welcome. If you are new to the Coder codebase, see the contribution guide to get started.

Hiring

Apply on the careers page if you are interested in joining the team.

S
Description
Provision remote development environments via Terraform
Readme AGPL-3.0
1 GiB
Languages
Go 74.9%
TypeScript 23.1%
Shell 0.8%
HCL 0.3%
PLpgSQL 0.3%
Other 0.4%