Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): handleErrors should display error cause if it exists #27886

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

AgentEnder
Copy link
Member

@AgentEnder AgentEnder commented Sep 11, 2024

Some error messages are not displaying properly, as they pass their original message as a cause. While node supports this, our handleErrors function was not displaying error causes.

"Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
            CreateMetadataError: The "test-plugin" plugin threw an error while creating metadata: cause message
            at /Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.spec.ts:17:29
            at handleErrors (/Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.ts:11:26)
            at Object.<anonymous> (/Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.spec.ts:15:23)
            at Promise.then.completed (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/utils.js:298:28)
            at new Promise (<anonymous>)
            at callAsyncCircusFn (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/utils.js:231:10)
            at _callCircusTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:316:40)
            at async _runTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:252:3)
            at async _runTestsForDescribeBlock (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:126:9)
            at async _runTestsForDescribeBlock (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:121:9)
            at async run (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:71:3)
            at async runAndTransformResultsToJestFormat (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
            at async jestAdapter (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
            at async runTestInternal (/Users/agentender/repos/nx/node_modules/.pnpm/jest-runner@29.7.0/node_modules/jest-runner/build/runTest.js:367:16)
            at async runTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-runner@29.7.0/node_modules/jest-runner/build/runTest.js:444:34)
        Caused by: 
            Error: cause message
              at /Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.spec.ts:16:21
              at handleErrors (/Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.ts:11:26)
              at Object.<anonymous> (/Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.spec.ts:15:23)
              at Promise.then.completed (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/utils.js:298:28)
              at new Promise (<anonymous>)
              at callAsyncCircusFn (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/utils.js:231:10)
              at _callCircusTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:316:40)
              at async _runTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:252:3)
              at async _runTestsForDescribeBlock (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:126:9)
              at async _runTestsForDescribeBlock (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:121:9)
              at async run (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:71:3)
              at async runAndTransformResultsToJestFormat (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
              at async jestAdapter (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
              at async runTestInternal (/Users/agentender/repos/nx/node_modules/.pnpm/jest-runner@29.7.0/node_modules/jest-runner/build/runTest.js:367:16)
              at async runTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-runner@29.7.0/node_modules/jest-runner/build/runTest.js:444:34)"
    `

@AgentEnder AgentEnder requested a review from a team as a code owner September 11, 2024 20:17
Copy link

vercel bot commented Sep 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Sep 12, 2024 8:32pm

@FrozenPandaz FrozenPandaz merged commit 1924bc3 into master Sep 12, 2024
6 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/expose-error-cause branch September 12, 2024 21:02
FrozenPandaz pushed a commit that referenced this pull request Sep 12, 2024
Some error messages are not displaying properly, as they pass their
original message as a cause. While `node` supports this, our
`handleErrors` function was not displaying error causes.

```
"Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
            CreateMetadataError: The "test-plugin" plugin threw an error while creating metadata: cause message
            at /Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.spec.ts:17:29
            at handleErrors (/Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.ts:11:26)
            at Object.<anonymous> (/Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.spec.ts:15:23)
            at Promise.then.completed (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/utils.js:298:28)
            at new Promise (<anonymous>)
            at callAsyncCircusFn (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/utils.js:231:10)
            at _callCircusTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:316:40)
            at async _runTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:252:3)
            at async _runTestsForDescribeBlock (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:126:9)
            at async _runTestsForDescribeBlock (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:121:9)
            at async run (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:71:3)
            at async runAndTransformResultsToJestFormat (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
            at async jestAdapter (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
            at async runTestInternal (/Users/agentender/repos/nx/node_modules/.pnpm/jest-runner@29.7.0/node_modules/jest-runner/build/runTest.js:367:16)
            at async runTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-runner@29.7.0/node_modules/jest-runner/build/runTest.js:444:34)
        Caused by:
            Error: cause message
              at /Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.spec.ts:16:21
              at handleErrors (/Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.ts:11:26)
              at Object.<anonymous> (/Users/agentender/repos/nx/packages/nx/src/utils/handle-errors.spec.ts:15:23)
              at Promise.then.completed (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/utils.js:298:28)
              at new Promise (<anonymous>)
              at callAsyncCircusFn (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/utils.js:231:10)
              at _callCircusTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:316:40)
              at async _runTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:252:3)
              at async _runTestsForDescribeBlock (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:126:9)
              at async _runTestsForDescribeBlock (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:121:9)
              at async run (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/run.js:71:3)
              at async runAndTransformResultsToJestFormat (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
              at async jestAdapter (/Users/agentender/repos/nx/node_modules/.pnpm/jest-circus@29.7.0/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
              at async runTestInternal (/Users/agentender/repos/nx/node_modules/.pnpm/jest-runner@29.7.0/node_modules/jest-runner/build/runTest.js:367:16)
              at async runTest (/Users/agentender/repos/nx/node_modules/.pnpm/jest-runner@29.7.0/node_modules/jest-runner/build/runTest.js:444:34)"
    `
```

(cherry picked from commit 1924bc3)
Copy link

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 Sep 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants