Skip to content

fix(release): unblock parallel publish race; manual fallback skips already-published#4

Merged
ohmaseclaro merged 1 commit into
mainfrom
fix/publish-race-condition
May 10, 2026
Merged

fix(release): unblock parallel publish race; manual fallback skips already-published#4
ohmaseclaro merged 1 commit into
mainfrom
fix/publish-race-condition

Conversation

@ohmaseclaro

Copy link
Copy Markdown
Owner

Summary

v0.3.0 publish ran via the changesets path (tag push) and 5/6 packages published cleanly: protocol, core, react, worker, cli all at 0.3.0. @atriumjs/express stalled with:

```
src/index.ts(15,8): error TS2307: Cannot find module '@atriumjs/core' or its corresponding type declarations.
src/middleware.ts(5,49): error TS2307: ...
src/middleware.ts(74,31): error TS7006: Parameter 'v' implicitly has an 'any' type.
```

Root cause

Changesets fires each package's `prepublishOnly` in parallel. `@atriumjs/core` and `@atriumjs/express` both had:

```json
"build": "rimraf dist && tsc -p tsconfig.json"
```

So two rimrafs ran concurrently:

  • `core/build`: `rimraf core/dist` → `tsc` emits core's `.d.ts`
  • `express/build`: `rimraf express/dist` → `tsc` reads `../core/dist/index.d.ts`

When core's `rimraf` won the race, express's tsc resolved `@atriumjs/core` against a directory that had been wiped and not yet rebuilt → the typechecker fell through to "implicit any" / "module not found" errors and express's prepublishOnly exited 2.

Fixes

  1. Drop `rimraf dist` from `@atriumjs/core` and `@atriumjs/express` builds. `tsc` overwrites files; the only loss is that a stale `.js` left over from a deleted `.ts` would linger, which is irrelevant for a one-shot publish run. The destructive clean moves to a separate `pnpm run clean` script for anyone who needs it (CI doesn't).

  2. `workflow_dispatch` fallback skips already-published versions. The previous loop ran `npm publish` unconditionally with `set -e`, so a retry after a partial publish (like this one) halts on the first 403 and never reaches the missing package. Now we `npm view` first and skip when the registry already has that exact version.

How to ship @atriumjs/express@0.3.0 after this merges

  1. Merge this PR.
  2. Run `Publish to npm` workflow with `workflow_dispatch` from the Actions tab.
  3. Loop iterates packages in dependency order; skips protocol/core/react/worker/cli (all already at 0.3.0); publishes express@0.3.0.
  4. Verify `npm view @atriumjs/express version` returns `0.3.0`.

Test plan

  • `pnpm run build:libs` clean (sequential build, no errors)
  • Prettier check passes on edited files
  • After merge: CI on main green
  • After workflow_dispatch run: `npm view @atriumjs/express version` returns `0.3.0`

…ready-published

Two coupled fixes after the v0.3.0 publish run dropped @atriumjs/express
on the floor:

1. core/express build no longer does `rimraf dist && tsc`.

   Changesets publishes packages in parallel. Each package's
   prepublishOnly runs `pnpm run build`. The combined effect was:

   - core/build:    rimraf core/dist  → tsc emits core/dist/*.d.ts
   - express/build: rimraf express/dist → tsc reads ../core/dist

   When the two rimrafs interleaved, express's tsc saw core's dist
   mid-rebuild and failed with "Cannot find module '@atriumjs/core'".

   Fix: drop `rimraf` from the build script — tsc overwrites files,
   stale `.js` left over from removed sources is a non-issue for a
   short-lived publish run. Move the destructive clean into a separate
   `clean` script for anyone who needs it.

   Symptom in the v0.3.0 run: 5 of 6 packages published successfully;
   @atriumjs/express stayed at 0.2.0 on npm.

2. workflow_dispatch fallback now skips already-published versions.

   The previous loop ran `npm publish` unconditionally and `set -e`
   would halt on the first 403 (version already on npm), so a retry
   after a partial publish couldn't proceed past the first
   already-published package. Now we `npm view` first and skip when
   the registry already has that exact version.

After this lands on main, trigger `Publish to npm` via workflow_dispatch
to ship @atriumjs/express@0.3.0.
@ohmaseclaro ohmaseclaro merged commit 443131c into main May 10, 2026
2 checks passed
@ohmaseclaro ohmaseclaro deleted the fix/publish-race-condition branch May 10, 2026 20:52
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.

1 participant