Skip to content

flake: TestWorkspaceApps/WorkspaceAppsProxySubdomain/ProxyError #960

Closed
coder/coder
#20827

Description

@blink-so

CI Failure Details

CI Run Link: https://github.com/coder/coder/actions/runs/17422692628
Commit: 6606d8b6420e1da55a8262599dc7879c879fb003 (hugodutka)
Platform: macOS (nightly-gauntlet)
Date: 2025-09-03 04:16:41 GMT

Error Analysis

The test TestWorkspaceApps/WorkspaceAppsProxySubdomain/ProxyError is failing with a timeout in the assertWorkspaceLastUsedAtUpdated function. The test expects the workspace's LastUsedAt timestamp to be updated after making a request to a workspace app, but this condition is never satisfied within the timeout period.

Key Error Message:

Error Trace: /Users/runner/work/coder/coder/coderd/workspaceapps/apptest/apptest.go:2475
Error: Condition never satisfied
Test: TestWorkspaceApps/WorkspaceAppsProxySubdomain/ProxyError

Test Flow:

  1. Test makes a request to a fake workspace app via subdomain proxy
  2. Expects HTTP 502 Bad Gateway response (which it gets)
  3. Calls assertWorkspaceLastUsedAtUpdated to verify workspace usage tracking
  4. The assertion fails because after.LastUsedAt.After(before.LastUsedAt) never becomes true

Root Cause Assessment

This appears to be a timing/race condition issue in the workspace app statistics collection system. The test expects that even failed requests (502 errors) should update the workspace's LastUsedAt timestamp, but the stats collection may be:

  1. Asynchronous timing issue: The stats are collected asynchronously and may not be flushed within the test timeout
  2. Race condition: The connection close event and stats collection may be racing
  3. Failed request handling: The 502 error case may not be properly triggering usage stats updates

Reproduction

This failure occurred in the nightly gauntlet on macOS. The test may be flaky due to timing differences on different platforms or under different load conditions.

Related Code

  • Test file: coderd/workspaceapps/apptest/apptest.go (lines 1426-1438)
  • Assertion function: assertWorkspaceLastUsedAtUpdated (lines 2469-2483)
  • The assertion uses require.Eventually with testutil.WaitShort and testutil.IntervalMedium

Activity

  1. johnstcn commented on Sep 23, 2025

    @johnstcn
    Member

    Should be fixed by coder/coder#19918.
    Please reopen if this is not the case.

  2. blink-so commented on Oct 13, 2025

    @blink-so
    Author

    New Occurrence - 2025-10-13

    This test flaked again on the nightly gauntlet run.

    CI Run Link: https://github.com/coder/coder/actions/runs/18454797808/job/52574332330
    Commit: d9f95f22858bd8a94839b354ed902fa18428d1ac (main branch)
    Platform: Windows 2022 (nightly-gauntlet)
    Date: 2025-10-13 04:20:05 GMT

    Test Result

    --- FAIL: TestWorkspaceApps/WorkspaceAppsProxySubdomain/ProxyError (29.87s)
    

    The test took approximately 30 seconds before failing, suggesting this is hitting the testutil.WaitLong timeout.

    Pattern Analysis

    This is the same failure pattern as previous occurrences:

    • Previous: 2025-09-03 (macOS), 2025-09-30 (see last comment)
    • Current: 2025-10-13 (Windows 2022)
    • Frequency: ~2 weeks between occurrences
    • Cross-platform: Affects both macOS and Windows

    The test is consistently timing out waiting for the assertWorkspaceLastUsedAtUpdated assertion to pass, indicating the workspace LastUsedAt timestamp is not being updated after failed proxy requests (502 Bad Gateway).

    This suggests the fix in coder/coder#19918 may not have fully resolved the underlying race condition in the workspace app statistics collection system.

  3. assigned and unassigned on Nov 14, 2025
  4. added a commit that references this issue on Nov 25, 2025
    6ba3f3f
  5. flake-investigator commented on Mar 12, 2026

    @flake-investigator

    New occurrence on Windows nightly-gauntlet:

    Evidence from logs:

    === FAIL: enterprise TestWorkspaceApps/WorkspaceAppsProxySubdomain/ProxyError (31.44s)
    ...
    coderd.workspaceapps: workspace app unavailable: Agent state is "disconnected", not "connected" ... status_code=502
    

    Root cause assessment:

    • Matches prior flake pattern: likely assertWorkspaceLastUsedAtUpdated timing/race in workspace app stats flush (no panics/OOM/data races observed in logs).

    Assignment analysis:

    • git log --oneline -10 --follow coderd/workspaceapps/apptest/apptest.go shows recent functional changes by Cian Johnston:
      • 4c63ed760 "fix(workspaceapps): use fresh context in LastUsedAt assertions (#22863)"
      • 4a56a409 "chore: apptest: update test helpers to context-aware testutil.Eventually (#19918)"
    • Assigning to @johnstcn based on most recent non-trivial changes to the flaky helper/test path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions