Skip to content

fix(task-board): don't cache "no preview yet" for a full window - #7024

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/pr-card-preview-stale
Sep 4, 2026
Merged

fix(task-board): don't cache "no preview yet" for a full window#7024
pedrofrxncx merged 1 commit into
mainfrom
fix/pr-card-preview-stale

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Problem

A PR card read while its deploy is still running has no preview URL yet — and both caches store that not-ready answer as a normal value, then serve it as a fresh hit: the reads cache for 55s, the assembled card for 30s, layered. So the preview link shows up minutes after GitHub actually has it.

Seen on ELEC-245: the VTEX FastStore preview (sfj-a14bf72--electroluxecfaststore.preview.vtex.app) was live on PR #305 while the task card still showed only "3/9 successful checks" and no preview button.

Change

A per-entry hit-window override on fetch and fetchOrPlaceholder, computed from the stored value, used in the two places that can be incomplete:

  • the GET_PREVIEW_DEPLOYMENT read, when it carries no environmentUrl yet;
  • the assembled card, while checksStatus === "pending" and no preview has been found.

Both go stale immediately, so the next poll revalidates. Revalidation is already detached from the request path, so this costs one background rebuild per poll on exactly the cards still missing something — and nothing on the rest. A card that has its preview, or whose CI settled without one, caches normally again (isAwaitingPreview).

No TTL constants changed; no behaviour change for complete cards.

Testing

pr-cache.test.ts — two new cases pinning that a not-ready value is never a hit inside the default window, and that the override stops applying once the value is complete. checks-status.test.tsisAwaitingPreview truth table (preview found, CI passing, CI failing, no CI all cache normally).

bun test apps/api/src/tools/task-board/ → 465 pass. The 10 failures are ECONNREFUSED :5432 integration tests needing a local Postgres, unrelated. bun run fmt, bun run lint (0 errors), tsc --noEmit clean.


Summary by cubic

Fixes the task board caching "no preview yet" for the full window, so preview links now appear as soon as GitHub has them.

While a deploy is still running, both caches served the not-ready answer as a fresh hit — 55s for reads, 30s for the assembled card, layered — so the preview could show up minutes after GitHub had it (seen on ELEC-245).

What changed

  • Adds a per-entry hit-window override on fetch and fetchOrPlaceholder, computed from the stored value.
  • Applies it where a value can be incomplete: the GET_PREVIEW_DEPLOYMENT read with no environment URL yet, and the assembled card while checks are pending and no preview is found.
  • Incomplete values go stale immediately, so the next poll revalidates; the detached rebuild costs one background pass per poll on those cards only.
  • Cards that have a preview, or whose CI settled without one, cache normally again.
  • Adds tests for the override and the isAwaitingPreview logic.

Written for commit 725152a. Summary will update on new commits.

Review in cubic

A PR card read while its deploy is still running has no preview URL, and both
caches then serve that not-ready answer as a fresh hit — the reads cache for
55s, the assembled card for 30s, layered. So the preview link appears minutes
after GitHub actually has it. Seen on ELEC-245: the VTEX FastStore preview was
live on the PR while the task card still showed only "3/9 successful checks".

Add a per-entry hit-window override to both `fetch` and `fetchOrPlaceholder`,
computed from the stored value, and use it in the two places that can be
incomplete:

- the `GET_PREVIEW_DEPLOYMENT` read, when it carries no environment url yet;
- the assembled card, while checks are pending and no preview has been found.

Both go stale immediately, so the next poll revalidates. Revalidation is
already detached, so this costs a background rebuild per poll on exactly the
cards that are still missing something, and nothing on the rest — a card that
has its preview, or whose CI settled without one, caches normally again.
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) September 4, 2026 20:27
@pedrofrxncx
pedrofrxncx merged commit a927238 into main Sep 4, 2026
33 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/pr-card-preview-stale branch September 4, 2026 20:30
decocms Bot pushed a commit that referenced this pull request Sep 4, 2026
PR: #7024 fix(task-board): don't cache "no preview yet" for a full window
Bump type: patch

- decocms (apps/api/package.json): 4.332.1 -> 4.332.2
- @decocms/native (apps/native/package.json): 4.332.1 -> 4.332.2

Deploy-Scope: server
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