fix(publish-npm): use corepack to upgrade npm instead of npm self-install - #90
Merged
Conversation
chcmedeiros
self-requested a review
May 26, 2026 15:40
chcmedeiros
approved these changes
May 26, 2026
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.
Value
_publish-npm.yaml— the previousnpm install -g npm@lateststep has been failing on GitHub-hosted runners withCannot find module 'promise-retry'for the past ~2 months, breaking all dry-run publish checks and silently masking real publish-time errors.@lateststill resolves to latest), no input contract changes — drop-in compatible with every consumer pinned at v5/v6/v7/v8/v9.Why this broke now (the workflow line didn't change)
npm install -g npm@latestasks npm to upgrade itself in-place. While the upgrade is running, the old npm'snode_modules(includingpromise-retry) gets unlinked mid-install — and the running process then tries torequire('promise-retry')from those same paths.npm@latestrolled to npm 11.x, which uses arborist v8 with a reorganised internal layout. The running arborist v7 doesn't tolerate the new layout's deletion order —promise-retryis gone by the time arborist needs it duringrebuild.@latestresolves to has. Same trigger that would hit any other consumer the moment theirchecksjob starts passing.Technical
.github/workflows/_publish-npm.yaml— replacesnpm install -g npm@latestwithcorepack prepare npm@latest --activate. Corepack downloads npm as a tarball into its own cache and atomically swaps the active version — no self-modification, so the arborist-version mismatch can't bite.How we tested
Two consumers, four CI runs, all green:
kunobi-ninja/mcp-installerZondax/clikunobi-ninja/mcp-installerCI at this branch, ran it three times via empty-commit triggers. Three independent fresh runs — bothchecks-tsand thepublishdry-run green every time. Rules out flakes in corepack's tarball download.Zondax/cli(different major, different package shape, has a separateTest Build Introspectionmatrix on top of publish). Throwaway draft PR opened and closed without merging; thepublishjob ran for 32s and passed. Confirms the fix isn't accidentally coupled to mcp-installer's specifics._publish-npm.yamlexceptnpm publish --provenance(the actual upload — gated byif: !inputs.dry_run). After the corepack swap the resulting npm binary is the same tarball npm@latest produces directly, so the publish path is behaviourally identical to before.Sequence
After merging:
v6,v7,v8,v9) so existing consumers pick up the fix without changes.Related: Zondax/kunobi-frontend#1672 (the downstream feature work whose CI surfaced this), kunobi-ninja/mcp-installer#1 (currently blocked on this PR).