Skip to content

fix(cli): sweep leftover e2e projects by logicalId instead of name [RED-740] [ship] - #1461

Merged
sorccu merged 2 commits into
mainfrom
simo/red-740-e2e-sweep-logicalid
Aug 31, 2026
Merged

fix(cli): sweep leftover e2e projects by logicalId instead of name [RED-740] [ship]#1461
sorccu merged 2 commits into
mainfrom
simo/red-740-e2e-sweep-logicalid

Conversation

@sorccu

@sorccu sorccu commented Aug 31, 2026

Copy link
Copy Markdown
Member

Linear: RED-740

The untargeted leftover-project sweep in deploy.spec.ts (the no-argument cleanupProjects() run in beforeAll/afterAll) has never deleted anything: it matched project.name against 'e2e-test-deploy-project-', but that string is the logicalId prefix — the fixture's name is always 'Deploy Project', so the predicate was always false. Every e2e run that died between beforeEach and afterEach (e.g. a CI timeout) leaked a project into the shared test account; 144 orphans had accumulated when this was discovered.

The flip is deliberately the second of two commits, because it turns dead code into real network deletes inside hooks that run on Vitest's 10s default timeout with no failure tolerance:

  1. test(cli): harden the sweep while its delete path is still dead code.

    • The sweep never fails the suite: the whole sweep and each individual delete warn and move on instead of propagating out of the hook. Note the sweep's hand-rolled axios client has none of the rest/api interceptors, so errors stay raw AxiosErrors — deleteProject's ConflictError-based wait-for-predecessor loop (30-minute deadline) cannot engage here, and a concurrent shard's 409 fails fast into the sweep's catch.
    • Each delete is raced against a 60s sweep-wide budget: deleteProject streams an async deletion to completion with no request timeout, and a hook timeout aborts from outside any catch, so a backlog drain must self-limit. Remaining candidates are counted and reclaimed by later runs.
    • Observability: each reclaimed project is logged, every sweep ends with a scanned / matched / deleted summary line (an empty account must be distinguishable from a silently dead sweep — silence is how this went unnoticed), and a prefix-matched project with an unparseable created_at warns loudly instead of being silently skipped by an Invalid DateTime comparison.
    • hookTimeout: 120_000 in vitest.config.e2e.mts: every e2e hook is network-bound (the targeted afterEach delete also streams an async deletion), and the suite-level timeout option covers tests only.
  2. fix(cli): the one-line project.nameproject.logicalId predicate flip.

The 20-minute age guard is unchanged — it is what keeps the sweep safe against concurrent CI shards, since a live test project only exists for the duration of a single test (all deployed e2e projects use uuid-derived logicalIds).

The orphan backlog was purged manually when the ticket was filed, so the sweep faces only steady-state leakage (~1 project per crashed run). Its summary log line makes it observable in the e2e job output.

🤖 Generated with Claude Code

sorccu and others added 2 commits August 31, 2026 19:06
…740]

The untargeted sweep in deploy.spec.ts runs inside beforeAll/afterAll
hooks, which get Vitest's 10s default timeout and abort from outside any
catch. Before making the sweep actually delete anything (its predicate
is still dead code — flipped in the next commit), make it safe to run:

- Never fail the suite: the whole sweep and each individual delete are
  wrapped in try/catch that warns and moves on.
- Bound each delete by a 60s sweep-wide budget via Promise.race:
  deleteProject streams an async deletion to completion with no request
  timeout, so a single slow delete could otherwise outlive the hook
  timeout. Remaining candidates are counted and reclaimed by later runs.
- Log reclaimed projects and a per-sweep summary (scanned / matched /
  deleted), and warn on prefix-matched projects with unparseable
  created_at — an Invalid DateTime compares false silently, which would
  re-create the silent-dead-sweep failure mode this ticket is about.
- Set hookTimeout: 120_000 in vitest.config.e2e.mts: every e2e hook is
  network-bound (the targeted afterEach delete also streams an async
  deletion), and the suite-level timeout option covers tests only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ED-740]

The 'e2e-test-deploy-project-' prefix is the logicalId prefix —
deploy.spec.ts generates projectLogicalId = `e2e-test-deploy-project-
${uuidv4()}` while the fixture's projectName is hardcoded 'Deploy
Project' — so matching on project.name has never been true and the
untargeted sweep has never deleted anything. Orphaned projects from
crashed e2e runs (e.g. CI timeouts between beforeEach and afterEach)
accumulated in the shared test account indefinitely; 144 were found
when this was discovered.

The 20-minute age guard is unchanged: it is what keeps the sweep safe
against concurrent CI shards, since a live test project only exists for
the duration of a single test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sorccu sorccu changed the title fix(cli): sweep leftover e2e projects by logicalId instead of name [RED-740] fix(cli): sweep leftover e2e projects by logicalId instead of name [RED-740] [ship] Aug 31, 2026

@github-actions github-actions 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.

Auto-approved: ship/show PR from a same-repo branch.

@sorccu
sorccu merged commit 404d501 into main Aug 31, 2026
17 checks passed
@sorccu
sorccu deleted the simo/red-740-e2e-sweep-logicalid branch August 31, 2026 11:16
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.

1 participant