Skip to content

flake: TestSubscribeError/Flush #1617

Description

@flake-investigator

CI Run Link: https://github.com/coder/coder/actions/runs/29236112377
Failing Job: https://github.com/coder/coder/actions/runs/29236112377/job/86771135015 (test-go-pg (ubuntu-latest))
Failure time: 2026-07-13T08:52:09Z (same window as Slack alert)

Commit Info:

Failure evidence:

=== FAIL: coderd/x/nats TestSubscribeError/Flush (0.00s)
t.go:114: 2026-07-13 08:49:20.348 [erro] failed to unsubscribe after error subscribing event=foo error="nats: connection closed" ...
previous_error= flush subscribe:
github.com/coder/coder/v2/coderd/x/nats.(*Pubsub).subscribeGroup
/home/runner/work/coder/coder/coderd/x/nats/pubsub.go:756
- assert.AnError general error for testing
pubsub_internal_test.go:594:
Error Trace: /home/runner/work/coder/coder/coderd/x/nats/pubsub_internal_test.go:594
Error: Should be empty, but was map[foo:0x90912dc3340]
Test: TestSubscribeError/Flush

Error analysis:

  • TestSubscribeError/Flush expects ps.subscriptions to be empty after a failed subscribe/flush path, but a subscription for foo remains.
  • The log shows nats: connection closed during unsubscribe after the error, which likely leaves stale state in ps.subscriptions.

Root cause classification:

  • Flaky test / timing/cleanup issue in NATS pubsub subscribe error handling (state not fully cleaned up when connection closes after error).

Data race / panic / OOM checks:

  • No WARNING: DATA RACE, panic:, or OOM indicators observed in the failing job log tail.

Precise assignment analysis:

  • Failing test function:
    • coderd/x/nats/pubsub_internal_test.go lines ~556-600 (TestSubscribeError with Flush subtest)
  • Intended blame command:
    • git blame -L 556,600 coderd/x/nats/pubsub_internal_test.go
  • Recent file history (best available via git log):
    • a6afcd0 "fix: prevent deadlock between async error handling and failed subscribes (#27109)" by Jon Ayers
    • 6da322d "feat: add Prometheus metrics to NATS pubsub for parity with PGPubsub (#26441)" by Jon Ayers

Assignment:

  • Best candidate: @sreya (recent NATS pubsub work and prior NATS flakes assigned here; please reassign if ownership differs)

Related issues search (coder/internal):

Reproduction (best effort):

go test ./coderd/x/nats -run TestSubscribeError/Flush -count=1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions