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): show better errors #29525

Merged
merged 1 commit into from
Jan 14, 2025
Merged

fix(core): show better errors #29525

merged 1 commit into from
Jan 14, 2025

Conversation

AgentEnder
Copy link
Member

@AgentEnder AgentEnder commented Jan 6, 2025

Current Behavior

Sub-errors are hidden when any project graph error is encountered. This is detrimental, as things like "missing comma in JSON" get hidden and make people think that Nx is broken, when in fact their config files are invalid.

Expected Behavior

Sub errors are shown regardless of verbose logging (but including their stack trace if verbose logging is enabled)

Without Verbose

image

With Verbose

image

Related Issue(s)

Fixes #

@AgentEnder AgentEnder requested a review from a team as a code owner January 6, 2025 16:02
Copy link

vercel bot commented Jan 6, 2025

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 Jan 14, 2025 3:38am

@AgentEnder AgentEnder requested a review from JamesHenry January 7, 2025 22:11
@AgentEnder AgentEnder force-pushed the fix/show-better-errors branch from 326d9b0 to 65466a2 Compare January 7, 2025 23:20
Copy link

nx-cloud bot commented Jan 7, 2025

View your CI Pipeline Execution ↗ for commit df82ea9.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 37m 13s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 58s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx format:check --base=61815... ✅ Succeeded 14s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 13s View ↗
nx documentation --no-dte ✅ Succeeded 59s View ↗

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

@AgentEnder AgentEnder force-pushed the fix/show-better-errors branch from 65466a2 to 9ed7de2 Compare January 8, 2025 18:35
Copy link
Collaborator

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

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

I malformed the project.json of cart and these are the logs that I get:

Non Verbose:

~/p/nx-examples (master|✚4) [1]$ nx show projects

 NX   Failed to process project graph, there may be an issue with one of your Nx plugins. If the cause is not obvious from the error message, running "nx reset" may fix it. Please report the issue if you keep seeing it. See errors below.

  - apps/cart/project.json: CommaExpected in /home/jason/projects/nx-examples/apps/cart/project.json at 7:3
   5 |   "projectType": "application",
   6 |   "generators": {}
>  7 |   "targets": {
     |   ^^^^^^^^^
   8 |     "build": {
   9 |       "executor": "@nx/webpack:webpack",
  10 |       "options": {

  - apps/cart/jest.config.ts: CommaExpected in apps/cart/project.json at 7:3
   5 |   "projectType": "application",
   6 |   "generators": {}
>  7 |   "targets": {
     |   ^^^^^^^^^
   8 |     "build": {
   9 |       "executor": "@nx/webpack:webpack",
  10 |       "options": {

The projects in the following directories have no name provided:
  - apps/cart

These logs are better than what it was before but they're still missing some information which would be helpful.

I think the plugin name or index would allow people to identify which plugin was causing the error... I almost feel like there's a line missing before the JSON error 🤔

readonly #partialProjectGraph: ProjectGraph;
readonly #partialSourceMaps: ConfigurationSourceMaps;

constructor(
errors: Array<
private readonly errors: Array<
Copy link
Collaborator

Choose a reason for hiding this comment

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

This allows errors get serialized right?

Comment on lines 240 to 242
error.message = `${
error.errors.length > 1 ? `${error.errors.length} errors` : 'An error'
} occurred while processing files for the ${pluginName} plugin.`;
Copy link
Member Author

Choose a reason for hiding this comment

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

This gets overwritten

@AgentEnder AgentEnder force-pushed the fix/show-better-errors branch 2 times, most recently from cdca42d to 73db4d8 Compare January 14, 2025 02:18
@AgentEnder AgentEnder force-pushed the fix/show-better-errors branch from 73db4d8 to df82ea9 Compare January 14, 2025 03:36
@FrozenPandaz FrozenPandaz merged commit c060b3a into master Jan 14, 2025
6 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/show-better-errors branch January 14, 2025 20:29
FrozenPandaz pushed a commit that referenced this pull request Jan 15, 2025
## Current Behavior
Sub-errors are hidden when any project graph error is encountered. This
is detrimental, as things like "missing comma in JSON" get hidden and
make people think that Nx is broken, when in fact their config files are
invalid.

## Expected Behavior
Sub errors are shown regardless of verbose logging (but including their
stack trace if verbose logging is enabled)

### Without Verbose

![image](https://github.com/user-attachments/assets/3a96d07e-3f0a-4eb7-8629-0c02c6912746)

### With Verbose

![image](https://github.com/user-attachments/assets/41b83e19-e6b1-471c-80ca-004b8f56d8f2)

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

(cherry picked from commit c060b3a)
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 Jan 20, 2025
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.

3 participants