Skip to content

Can't determine real reason behind fail of nx release publish due to inaccurate error handling #22210

@tabomors

Description

@tabomors

Current Behavior

Currently on Gitlab CI we try are tryng to run nx release publish but it fails with error Cannot read properties of undefined (reading 'summary') on this line https://github.com/nrwl/nx/blob/master/packages/js/src/executors/release-publish/release-publish.impl.ts#L240. This log hides the true cause of the error. It happens because this line https://github.com/nrwl/nx/blob/master/packages/js/src/executors/release-publish/release-publish.impl.ts#L237C7-L237C69 actually an empty object then it tries to get error.summary from it and fails

Expected Behavior

If there is no stdoutData.error I would expect to see original error:

const stdoutData = JSON.parse(err.stdout?.toString() || '{}');

console.error('npm publish error:');
if (err.stdout) {
  if (stdoutData.error.summary) {
    console.error(stdoutData.error.summary);
  }
  if (stdoutData.error.detail) {
    console.error(stdoutData.error.detail);
  }
} else {
  console.error(err);
}

GitHub Repo

No response

Steps to Reproduce

Unfortunately I am not sure why this code goes to this point and how to provide steps to reproduce. I hope if error handling would be improved I can get back to this thread with more information

Nx Report

Node   : 18.12.0
OS     : linux-x64
npm    : 8.19.4
nx                 : 18.0.7
@nx/js             : 18.0.7
@nx/jest           : 18.0.7
@nx/linter         : 18.0.7
@nx/eslint         : 18.0.7
@nx/workspace      : 18.0.7
@nx/devkit         : 18.0.7
@nx/esbuild        : 18.0.7
@nx/eslint-plugin  : 18.0.7
@nx/nest           : 18.0.7
@nx/node           : 18.0.7
@nx/plugin         : 18.0.7
@nrwl/tao          : 18.0.7
@nx/webpack        : 18.0.7
typescript         : 5.3.3

Failure Logs

npm WARN config `_auth`, `_authToken`, `username` and `_password` must be scoped to a registry. see `npm help npmrc` for more information.
npm WARN config `_auth`, `_authToken`, `username` and `_password` must be scoped to a registry. see `npm help npmrc` for more information.
npm publish error:
Something unexpected went wrong when processing the npm publish output
 TypeError: Cannot read properties of undefined (reading 'summary')
    at runExecutor (/builds/ifi/frontend/core/.cache/modules-18/node_modules/@nx/js/src/executors/release-publish/release-publish.impl.js:176:34)
    at runExecutorInternal (/builds/ifi/frontend/core/.cache/modules-18/node_modules/nx/src/command-line/run/run.js:88:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /builds/ifi/frontend/core/.cache/modules-18/node_modules/nx/src/command-line/run/run.js:169:44
    at async handleErrors (/builds/ifi/frontend/core/.cache/modules-18/node_modules/nx/src/utils/params.js:9:16)
    at async process.<anonymous> (/builds/ifi/frontend/core/.cache/modules-18/node_modules/nx/bin/run-executor.js:59:28)

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions