Conversation
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for nx-dev pending review.Visit the deploys page to approve it
|
jaysoo
approved these changes
Sep 15, 2026
The release-publish executor runs
`npm view <pkg> versions dist-tags --json` to check for existing
dist-tags before publishing. Some registries (e.g. GitHub Packages)
return empty stdout with a zero exit code when the package exists but
has no published versions/dist-tags yet.
In that case `JSON.parse('')` threw "Unexpected end of JSON input".
Because the resulting SyntaxError carries no stdout/stderr, it fell
through the E404/404 guards in the catch block and was surfaced as
"Something unexpected went wrong when checking for existing dist-tags",
aborting the publish.
Treat empty view output the same as the package not existing yet: skip
the dist-tag lookup and continue to the publish step. Adds a regression
test covering the empty-output case.
jaysoo
force-pushed
the
fix/36358-nx-release-publish-fails-when-package-ex
branch
from
September 15, 2026 17:55
90812c5 to
4876bb3
Compare
Contributor
|
View your CI Pipeline Execution ↗ for commit 4332b91
☁️ Nx Cloud last updated this comment at |
jaysoo
approved these changes
Sep 15, 2026
jaysoo
enabled auto-merge (squash)
September 15, 2026 18:03
Contributor
There was a problem hiding this comment.
Nx Cloud has identified a flaky task in your failed CI:
Since the failure was identified as flaky, the solution is to rerun CI. Because this branch comes from a fork, it is not possible for us to push directly, but you can rerun by pushing an empty commit:
git commit --allow-empty -m "chore: trigger rerun"
git push
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
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.
Current Behavior
nx release publish(the@nx/jsrelease-publish executor) runsnpm view <pkg> versions dist-tags --jsonto check for existing dist-tags before publishing. Some registries — notably GitHub Packages — return empty stdout with a zero exit code when the package exists but has no published versions/dist-tags yet.In that case
JSON.parse('')throwsSyntaxError: Unexpected end of JSON input. Because the resultingSyntaxErrorcarries nostdout/stderr, it falls through theE404/404guards in the surroundingcatchblock and is surfaced as:The publish then aborts, making it impossible to (re)publish a package that exists but has no
latesttag yet (e.g. a pre-release that only has anextdist-tag).Expected Behavior
Empty
npm viewoutput is treated the same as the package not existing yet: the dist-tag lookup is skipped and publishing continues, so pre-release / first-time publishes to registries that return empty output succeed.The
JSON.parseis guarded with an empty-output check (result.toString().trim()→ fall back to{}). A regression test mocksnpm viewreturning empty stdout and asserts the executor proceeds to publish (threeexecSynccalls:npm --version,npm view, publish) instead of reporting the spurious "Something unexpected went wrong when checking for existing dist-tags" failure.Related Issue(s)
Fixes #36358