Skip to content

fix(NOJIRA-123): clean stale nested node_modules on cache restore-key fallback#226

Merged
kb-typeform merged 1 commit intomainfrom
fix/stale-cache-nested-node-modules-cleanup
Apr 14, 2026
Merged

fix(NOJIRA-123): clean stale nested node_modules on cache restore-key fallback#226
kb-typeform merged 1 commit intomainfrom
fix/stale-cache-nested-node-modules-cleanup

Conversation

@kb-typeform
Copy link
Copy Markdown
Contributor

Overview

Fix stale cache restore-key fallback causing version conflicts during major dependency migrations (e.g., React 17→18). When actions/cache restores via restore-key fallback, yarn install --frozen-lockfile does not delete leftover nested node_modules/ from the stale cache, causing TypeScript type mismatches.

Context: https://github.com/Typeform/share-web/pull/960 — share-web had to add a postinstall hack to work around this.

Changes

  • Add "Clean stale nested node_modules on restore-key fallback" step to setup-node-with-cache/action.yml
  • Detect restore-key fallback (cache restored but cache-hit != true) and purge all nested node_modules/ directories inside dependencies before yarn install
  • Also clean nested dirs in workspace packages (packages/*/, apps/*/)
  • Remove .yarn-integrity on fallback to force full resolution
  • Document the new behavior in README.md under "Stale Cache Cleanup" section

Impact

  • Exact cache hit: Zero impact (cleanup step is skipped)
  • Restore-key fallback: Adds ~5-10s for find + rm -rf, but prevents broken builds from stale transitive dependencies
  • Clean miss: Negligible (directory existence check only)

… fallback

When actions/cache restores via restore-key fallback (not exact match),
yarn install --frozen-lockfile does not delete leftover nested
node_modules/ dirs from the stale cache. This causes version conflicts
during major dependency migrations (e.g., @types/react@17 persisting
inside echo-ui/node_modules after upgrading to React 18).

Add a cleanup step that detects restore-key fallback and purges all
nested node_modules directories before yarn install runs.
@kb-typeform kb-typeform force-pushed the fix/stale-cache-nested-node-modules-cleanup branch from aff3a7f to 84feb1c Compare April 14, 2026 09:46
@sonarqubecloud
Copy link
Copy Markdown

@kb-typeform kb-typeform marked this pull request as ready for review April 14, 2026 09:47
@kb-typeform kb-typeform requested a review from a team as a code owner April 14, 2026 09:47
@gitstream-cm
Copy link
Copy Markdown

gitstream-cm bot commented Apr 14, 2026

🥷 Code experts: no user but you matched threshold 10

kb-typeform has most 👩‍💻 activity in the files.
kb-typeform has most 🧠 knowledge in the files.

See details

shared-actions/setup-node-with-cache/README.md

Activity based on git-commit:

kb-typeform
APR
MAR
FEB 31 additions & 0 deletions
JAN 97 additions & 5 deletions
DEC 178 additions & 0 deletions
NOV

Knowledge based on git-blame:
kb-typeform: 100%

shared-actions/setup-node-with-cache/action.yml

Activity based on git-commit:

kb-typeform
APR
MAR
FEB 49 additions & 9 deletions
JAN 132 additions & 27 deletions
DEC 146 additions & 1 deletions
NOV

Knowledge based on git-blame:
kb-typeform: 93%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

@kb-typeform kb-typeform merged commit b50ced8 into main Apr 14, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants