Skip to content

fix(ci): pin Next.js sandbox cache key, drop poisoning restore-keys fallback - #2945

Merged
ejhammond merged 1 commit into
mainfrom
navi/fix/nextjs-cache-key-poisoning
Jun 20, 2026
Merged

ejhammond merged 1 commit into
mainfrom
navi/fix/nextjs-cache-key-poisoning

Conversation

@ejhammond

Copy link
Copy Markdown
Contributor

Problem

The post-merge deploy job for the XDS un-prefix migration (#2941) failed at Build Sandbox with:

  • Attempted import error: 'Text' is not exported from '@xds/core/Text' (theme-showcase)
  • Error: Element type is invalid ... got: undefined prerendering /pages/butter-palette

…even though the same commit's PR CI build passed (byte-identical tree).

Root cause: poisoned Next.js build cache via restore-keys fallback

apps/sandbox/.next/cache bakes in the resolved export graph of @xds/core. The cache key correctly included hashFiles('packages/core/dist/**'), but the loose restore-keys fallback defeated it:

key: nextjs-sandbox-<lock>-<core/dist>
restore-keys: |
  nextjs-sandbox-<lock>-     # ← matches ANY core/dist (any export shape)
  nextjs-sandbox-            # ← matches ANYTHING

Sequence:

  1. feat: XDS un-prefix migration — bare names canonical, XDS* compat aliases #2941 changed core's exports (bare names canonical + new ./astryx.css, ./naming subpaths) → new packages/core/dist/** hash → new cache key.
  2. On main, the exact key missed. GitHub Actions caches are ref-scoped: the post-migration caches existed only on refs/pull/2941/merge, unreadable from main.
  3. restore-keys fell back to a pre-migration main cache (built ~6h earlier) whose compiled Next modules still expected XDS*-prefixed exports.
  4. next build reused those stale modules against the new bare-name source → the import/prerender failures above.
  5. The PR build passed because its PR-scoped cache was built post-migration and was internally consistent.

(Confirmed empirically: deleting the stale main-ref nextjs-sandbox-* caches and re-running the deploy builds clean.)

Fix

Remove the restore-keys fallback in both deploy.yml and ci.yml. The key still keys on the lock + core dist hashes, so a change now yields a cold cache (a correct, slightly slower rebuild) instead of a poisoned warm one.

Risk

Low. Worst case is a one-time cold Next build whenever pnpm-lock.yaml or @xds/core dist changes — which is exactly when reusing the cache is unsafe.

…allback

The Next.js build cache (apps/sandbox/.next/cache) bakes in the resolved
export graph of @xds/core. The cache key included the @xds/core dist hash,
but the loose restore-keys fallback (nextjs-sandbox-<lock>- and
nextjs-sandbox-) let a build restore a cache produced against a DIFFERENT
export shape.

This broke the post-merge deploy of the XDS un-prefix migration (#2941):
- The migration changed core's exports (bare names canonical, new ./astryx.css
  and ./naming subpaths), changing hashFiles('packages/core/dist/**').
- On main, the exact cache key missed (no main-ref cache had the new dist hash;
  the post-migration caches were PR-ref scoped and unreadable from main).
- restore-keys fell back to a pre-migration main cache (built ~6h earlier) whose
  compiled Next modules still expected XDS*-prefixed exports.
- next build reused those stale modules against bare-name source, producing
  'Text' is not exported from '@xds/core/Text' and 'Element type is invalid ...
  undefined' prerender failures (e.g. /pages/butter-palette).
- The PR CI build passed because its PR-scoped cache was built post-migration
  and was therefore consistent.

Removing restore-keys makes a changed key yield a COLD cache (correct, slightly
slower rebuild) instead of a poisoned warm one. Applied to both deploy.yml and
ci.yml.
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

@ejhammond must be a member of the Meta Open Source team on Vercel to deploy.
- Click here to add @ejhammond to the team.
- If you initiated this build, request access.

Learn more about collaboration on Vercel and other options here.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Vercel Preview Deployment

Status ❌ Failed
Commit ecc9ae8
Workflow View Logs

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@ejhammond
ejhammond merged commit 7f5b074 into main Jun 20, 2026
21 of 22 checks passed
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
…allback (#2945)

The Next.js build cache (apps/sandbox/.next/cache) bakes in the resolved
export graph of @xds/core. The cache key included the @xds/core dist hash,
but the loose restore-keys fallback (nextjs-sandbox-<lock>- and
nextjs-sandbox-) let a build restore a cache produced against a DIFFERENT
export shape.

This broke the post-merge deploy of the XDS un-prefix migration (#2941):
- The migration changed core's exports (bare names canonical, new ./astryx.css
  and ./naming subpaths), changing hashFiles('packages/core/dist/**').
- On main, the exact cache key missed (no main-ref cache had the new dist hash;
  the post-migration caches were PR-ref scoped and unreadable from main).
- restore-keys fell back to a pre-migration main cache (built ~6h earlier) whose
  compiled Next modules still expected XDS*-prefixed exports.
- next build reused those stale modules against bare-name source, producing
  'Text' is not exported from '@xds/core/Text' and 'Element type is invalid ...
  undefined' prerender failures (e.g. /pages/butter-palette).
- The PR CI build passed because its PR-scoped cache was built post-migration
  and was therefore consistent.

Removing restore-keys makes a changed key yield a COLD cache (correct, slightly
slower rebuild) instead of a poisoned warm one. Applied to both deploy.yml and
ci.yml.
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
…allback (#2945)

The Next.js build cache (apps/sandbox/.next/cache) bakes in the resolved
export graph of @xds/core. The cache key included the @xds/core dist hash,
but the loose restore-keys fallback (nextjs-sandbox-<lock>- and
nextjs-sandbox-) let a build restore a cache produced against a DIFFERENT
export shape.

This broke the post-merge deploy of the XDS un-prefix migration (#2941):
- The migration changed core's exports (bare names canonical, new ./astryx.css
  and ./naming subpaths), changing hashFiles('packages/core/dist/**').
- On main, the exact cache key missed (no main-ref cache had the new dist hash;
  the post-migration caches were PR-ref scoped and unreadable from main).
- restore-keys fell back to a pre-migration main cache (built ~6h earlier) whose
  compiled Next modules still expected XDS*-prefixed exports.
- next build reused those stale modules against bare-name source, producing
  'Text' is not exported from '@xds/core/Text' and 'Element type is invalid ...
  undefined' prerender failures (e.g. /pages/butter-palette).
- The PR CI build passed because its PR-scoped cache was built post-migration
  and was therefore consistent.

Removing restore-keys makes a changed key yield a COLD cache (correct, slightly
slower rebuild) instead of a poisoned warm one. Applied to both deploy.yml and
ci.yml.
@cixzhang
cixzhang deleted the navi/fix/nextjs-cache-key-poisoning branch June 21, 2026 17:02

This branch had an error being deployed

1 failed deployment
Preview — ecc9ae8f Deployed Jun 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants