Skip to content

fix(build): fail loudly on a broken install, and clean-install on Vercel - #108

Merged
ephbaum merged 2 commits into
mainfrom
claude/astro-check-fail-loud
Oct 23, 2026
Merged

ephbaum merged 2 commits into
mainfrom
claude/astro-check-fail-loud

Conversation

@ephbaum

@ephbaum ephbaum commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

📝 What's This PR About?

Type of Change:

  • 🏗️ Infrastructure - Build, deployment, or tooling changes

📋 Description

Two commits. The first makes a broken install fail the build instead of silently skipping the type check. The second fixes the broken install on Vercel that the first commit exposed straight away.

For Technical Changes:

  • What changed:
    • astro:check is now astro sync && astro-check, replacing astro check. build, check and check:fix call pnpm run astro:check, so the command is defined once.
    • Vercel's installCommand is now rm -rf node_modules && pnpm install --frozen-lockfile, replacing pnpm install.
    • Docs and comments updated to match.
  • Why: both are explained below.
  • Impact: package.json scripts, vercel.json, and wording in CLAUDE.md, README.md, the ci.yml comment and the session-start hook comment. No change to what gets built.

f4360f7: astro-check instead of astro check

If @astrojs/check fails to import, astro check logs [ERROR] and then exits 0: a non-boolean return falls through to process.exit(0) in astro/dist/cli/index.js. Under CI (GitHub Actions and Vercel both count), ci-info skips the install prompt entirely. So a broken install turns the type-check gate into a silent no-op.

astro-check is the bin that ships with @astrojs/check. It imports the package statically, so the same breakage crashes with ERR_MODULE_NOT_FOUND, names the actual missing package, and exits 1.

The astro sync keeps parity, since astro check syncs before checking. Without it, a fresh checkout with no .astro/ reports 4 false errors.

Second commit: clean-install node_modules on Vercel

The first push failed on Vercel within seconds, and that failure was real. Vercel restores node_modules from its build cache and ran a plain incremental pnpm install.

pnpm records the optional packages it skipped in node_modules/.modules.yaml, and keeps skipping them on later installs even after a lockfile change makes them required:

  • before Astro 7.4, @emnapi/[email protected] was optional (wasm32 bindings only), so linux skipped it
  • after Astro 7.4, it's a hard dependency of @astrojs/astro2tsx

So cached Vercel deploys came up without it, and @astrojs/check couldn't load. With the old astro check that went unnoticed, which means #107's Vercel builds most likely deployed without type-checking. GitHub CI, which always installs clean, did type-check #107 and reported 0 errors, so nothing bad shipped.

I reproduced it locally by installing the pre-7.4 lockfile, then installing this one on top:

Install over a stale tree @emnapi/runtime @astrojs/check imports
pnpm install (old Vercel command) missing ❌
pnpm install --frozen-lockfile missing ❌
pnpm install --force present ✅, but installs every platform's optional binaries (19 @oxc-parser bindings)
rm -rf node_modules && pnpm install --frozen-lockfile present ✅, only this platform's binaries

🖼️ Visual Changes

  • No visual changes

🧪 Testing

  • Tested locally with pnpm run dev
  • Built successfully with pnpm run build
  • Preview deployment looks good
  • No console errors
  • Mobile responsive (if UI changes)

All runs used CI=true to match GitHub Actions and Vercel:

Scenario Before (astro check) After (astro sync && astro-check)
@emnapi/core removed from node_modules logs [ERROR], exit 0 ERR_MODULE_NOT_FOUND: @emnapi/core, exit 1; build also exits 1
Healthy install Result (36 files), 0 errors Result (36 files), 0 errors, exit 0
Type error injected n/a ts(2322), Result (37 files): 1 error, exit 1
No .astro/ directory n/a 0 errors (bare astro-check without sync: 4 false errors)

pnpm run build and pnpm run check pass: 215 pages, lint and format clean. That holds both from a clean install and from the stale tree after running the new Vercel install command.

📚 Documentation

  • README.md updated (explain what changed)

  • README: the command table, CI section and mermaid diagram describe the new script.

  • CLAUDE.md: records why it isn't plain astro check, why the astro sync matters, and why Vercel deletes node_modules before installing.

🔗 Related

✅ Checklist

  • Code follows project conventions
  • No linting errors
  • Preview deployment works correctly
  • Ready for review

🤖 Generated with Claude Code

https://claude.ai/code/session_011rvCtaiKiC4ZSvX9yewguJ

When `@astrojs/check` fails to import, `astro check` logs an error and
then falls through to process.exit(0) (astro/dist/cli/index.js). In CI
it doesn't even prompt: ci-info short-circuits the install offer. So a
broken install -- e.g. a missing transitive like @emnapi/core -- turns
the type-check gate into a silent no-op on CI and Vercel.

`astro:check` is now `astro sync && astro-check`: the bin from
@astrojs/check imports it statically, so the same breakage crashes with
ERR_MODULE_NOT_FOUND naming the real missing package, and exits 1. The
`astro sync` keeps parity with `astro check`, which syncs first; without
it a fresh checkout reports 4 false errors. build, check and check:fix
call `pnpm run astro:check` so the command is defined once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011rvCtaiKiC4ZSvX9yewguJ
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ephbaumdotdev Ready Ready Preview Oct 23, 2026 5:01am UTC

Vercel restores node_modules from its build cache and ran a plain
incremental `pnpm install`. pnpm records skipped optional packages in
node_modules/.modules.yaml and keeps skipping them on later installs,
even once a new lockfile makes them required. @emnapi/[email protected]
was optional (wasm32 bindings only) before Astro 7.4 and is a hard
dependency of @astrojs/astro2tsx after it, so cached deploys came up
without it and @astrojs/check could not load.

`astro check` hid that by exiting 0; with the previous commit's
astro-check the deploy fails instead, which is how this surfaced.
Reproduced locally by installing the pre-7.4 lockfile, then
incrementally installing this one: --frozen-lockfile alone doesn't
repair it, `rm -rf node_modules` first does. (--force also works but
installs every platform's optional binaries.)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011rvCtaiKiC4ZSvX9yewguJ
@ephbaum ephbaum changed the title fix(build): type-check with astro-check so a broken install fails loudly fix(build): fail loudly on a broken install, and clean-install on Vercel Oct 23, 2026
@ephbaum
ephbaum merged commit 877050e into main Oct 23, 2026
3 checks passed
@ephbaum
ephbaum deleted the claude/astro-check-fail-loud branch October 23, 2026 14:34

This branch was successfully deployed

1 active deployment
Preview — f2f35b9c Deployed Oct 23, 2026 by vercel[bot]
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.

2 participants