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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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 8, 2025 6:37pm

@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 9ed7de2.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 7m 47s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 21s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check --base=8dc10... ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗
nx documentation --no-dte ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-09 18:11:42 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants