Repository navigation
Conversation
The build-theme.prose and build-theme.import-path suites each need a
compiled @astryxdesign/core (theme build imports the built theme entry;
there is no in-CLI fallback generator). The CI test job runs the suite
without a prior core build, and Vitest runs test files in parallel
worker forks. Each suite's beforeAll independently ran
`if (!exists) pnpm -F @astryxdesign/core build`, so both workers saw
dist missing and launched concurrent builds that collided on the shared
packages/core/dist (core's build starts with `rimraf dist`): one worker
wiped dist while the other was mid-write, failing nondeterministically
("Could not resolve dist/index.js" or "ENOTEMPTY rmdir dist/hooks").
Extract a shared ensureCoreBuilt() helper that serializes the build
behind an atomic lock directory, so exactly one worker builds and the
rest wait for it to finish before reading dist. Includes stale-lock
recovery for a crashed/killed builder.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
josephfarina
approved these changes
Jul 4, 2026
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The two
build-themeCLI suites intermittently fail in thetestCI job with nondeterministic errors:error: Could not resolve ".../packages/core/dist/index.js"[Error: ENOTEMPTY: directory not empty, rmdir '.../packages/core/dist/hooks']followed by dozens ofCould not resolve "./<Component>/index.js"The different error each run is the tell: it's a race, not a logic bug.
Root cause
astryx theme buildimports the compiled@astryxdesign/core/themeentry — there's no in-CLI fallback generator — sobuild-theme.prose.test.mjsandbuild-theme.import-path.test.mjsboth need a builtpackages/core/dist. ThetestCI job runs the suite without a prior core build, and Vitest runs test files in parallel worker forks.Each suite's
beforeAllindependently did:When
distis absent, both workers pass theexistsSynccheck and launchpnpm -F @astryxdesign/core buildconcurrently. Core's build script starts withrimraf dist, so the two builds stomp the sharedpackages/core/dist: one worker wipes/rebuildsdistwhile the other is mid-write, producing the missing-artifact andENOTEMPTYfailures above. It's a classic TOCTOU — the check doesn't prevent two processes from both deciding to build.Fix
Extract a shared
ensureCoreBuilt()helper that serializes the build behind an atomic lock directory (mkdiris atomic across processes):dist.distalready exists, it's a no-op fast path (no rebuild).Both suites now call
ensureCoreBuilt()inbeforeAllinstead of racing.Verification
Run locally from a cold state (
rm -rf packages/core/dist), both suites in parallel:5 passedin ~31s.5 passedin ~3.8s.eslintclean on all three files; repo sync / package-boundary / changeset checks pass. No consumer-facing change, so no changeset.