Skip to content

fix(release): surface swallowed publish errors when stdout is not valid JSON - #35283

Merged
leosvelperez merged 1 commit into
nrwl:masterfrom
ekkolon:fix/release-publish-swallowed-errors
Apr 14, 2026
Merged

fix(release): surface swallowed publish errors when stdout is not valid JSON#35283
leosvelperez merged 1 commit into
nrwl:masterfrom
ekkolon:fix/release-publish-swallowed-errors

Conversation

@ekkolon

@ekkolon ekkolon commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Current Behavior

When npm publish or pnpm publish fails, the executor assumes err.stdout (always) contains valid JSON. If a lifecycle script (e.g. prepublishOnly) fails, it writes plaintext to stdout instead. This causes JSON.parse to throw and the actual error to be swallowed by the outer catch, printing only a generic "something unexpected went wrong" message.

Expected Behavior

Wrap JSON.parse(err.stdout...) in a try/catch block. If parsing fails, fall back to logging raw stderr/stdout directly and return early, so lifecycle script failures and other non-JSON errors are always visible to the user.

Related Issue(s)

Fixes #34497

…id JSON

When `npm publish` or `pnpm publish` fails, the executor assumes `err.stdout`
(always) contains valid JSON. If a lifecycle script (e.g. `prepublishOnly`) fails,
it writes plaintext to stdout instead. This causes `JSON.parse` to throw and the
actual error to be swallowed by the outer catch, printing only a generic
"something unexpected went wrong" message.

Wrap `JSON.parse(err.stdout...)` in a try/catch block. If parsing fails, fall back to
logging raw stderr/stdout directly and return early, so lifecycle script failures
and other non-JSON errors are always visible to the user.

Fixes nrwl#34497
@ekkolon
ekkolon requested a review from a team as a code owner April 14, 2026 09:36
@ekkolon
ekkolon requested a review from leosvelperez April 14, 2026 09:36
@netlify

netlify Bot commented Apr 14, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs canceled.

Name Link
🔨 Latest commit f9ebd3c
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69de0ab2991f160008066b12
@netlify

netlify Bot commented Apr 14, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev canceled.

Name Link
🔨 Latest commit f9ebd3c
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69de0ab28b3e260009b4495c
@nx-cloud

nx-cloud Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit f9ebd3c

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 46m 16s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx conformance:check ✅ Succeeded 7s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-14 12:37:19 UTC

@leosvelperez leosvelperez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@leosvelperez
leosvelperez merged commit dcd61cd into nrwl:master Apr 14, 2026
15 checks passed
@ekkolon
ekkolon deleted the fix/release-publish-swallowed-errors branch April 14, 2026 15:54
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants