fix(release): stop the publish hooks from racing each other - #140
Merged
Conversation
changeset publish runs every package concurrently, so each package's prepublishOnly ran rm -rf dist followed by a rebuild at the same time. core deleted its own dist while the fastify adapter was type checking against it, failing build:types with TS2307 and blocking @seamless-auth/fastify from publishing. release:stable already runs pnpm build in topological order before changeset publish, so the per-package rebuild was redundant. Replace it with a check that the dist output exists, which also keeps a publish from silently shipping a tarball with no dist.
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.
What broke
The release run for
Version Packagespublished@seamless-auth/core@0.11.0and@seamless-auth/express@0.11.0but failed to publish@seamless-auth/fastify@0.1.0. The visible error pointed attsup, butbuild:jsactually succeeded and the next script is what failed:Why
changeset publishbuilds its publish queue with a concurrency limit of 10, so all three packages publish at the same time (the run log shows all threePublishinglines on an identical timestamp). Each package'sprepublishOnlywaspnpm run clean && pnpm run build, andcleanisrm -rf dist.So
coredeleted its owndistwhile the fastify adapter was type checking against it.build:jssurvived because tsup marks@seamless-auth/coreas external and never resolves it;build:typesneeds the real declaration files. Express only escaped on timing, so this was a race that could hit either adapter.Confirmed by hiding
packages/core/distand running the fastifybuild:typeslocally, which reproduces the identical error list.The fix
release:stablealready runspnpm build(pnpm -r --sort build, topologically ordered) beforechangeset publish, and that ordered build succeeded in the failed run. The per-package rebuild inprepublishOnlywas redundant, and re-running it concurrently is what destroyed the correct build.Replaced it in all three packages with a non-destructive check that build output exists. Dropping the hook outright would also fix the race, but then publishing without a prior build would silently ship a tarball with no
dist, sincefilesjust omits a missing directory. The guard turns that into a failed publish instead.Verification
Run from the workspace root:
pnpm buildclean,pnpm testgreen (core 214 tests, express 150, fastify 23)distpresent and exits 1 with the message when it is absentprepublishOnlyhooks run concurrently and all exit 0, which is the exact scenario that failedpnpm packfor fastify produces a tarball containingdist/index.jsand the declarationsRelease impact
No changeset here on purpose. This is release plumbing rather than an adopter-facing change, and a pending changeset would make the changesets action open a Version Packages PR instead of publishing.
mainalready carries the0.1.0bump and changelog for fastify, so merging this triggers a publish run that skips the two packages already on npm and ships@seamless-auth/fastify@0.1.0.