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(react): Update error message for invalid remote name #19744

Merged

Conversation

ndcunningham
Copy link
Contributor

Current Behavior

Currently, when you have an invalid remote you only get this error.

 >  NX   Cannot read properties of undefined (reading 'data')


TypeError: Cannot read properties of undefined (reading 'data')
    at readCachedProjectConfiguration (/private/tmp/projects/react-mfe/node_modules/nx/src/project-graph/project-graph.js:47:17)
    at /private/tmp/projects/react-mfe/node_modules/@nx/react/src/module-federation/utils.js:11:88
    at handleStringRemote (/private/tmp/projects/react-mfe/node_modules/@nx/webpack/src/utils/module-federation/remotes.js:45:30)
    at mapRemotes (/private/tmp/projects/react-mfe/node_modules/@nx/webpack/src/utils/module-federation/remotes.js:20:37)
    at getModuleFederationConfig (/private/tmp/projects/react-mfe/node_modules/@nx/react/src/module-federation/utils.js:62:25)
    at withModuleFederation (/private/tmp/projects/react-mfe/node_modules/@nx/react/src/module-federation/with-module-federation.js:11:112)
    at Object.<anonymous> (/private/tmp/projects/react-mfe/home/webpack.config.js:15:3)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Object.require.extensions.<computed> [as .js] (/private/tmp/projects/react-mfe/node_modules/ts-node/src/index.ts:1608:43)

Expected Behavior

Have a better error message.

Cannot find project "remoteDoesNotExists". Check that the name is correct in your module-federation config file.

Related Issue(s)

Fixes #

@ndcunningham ndcunningham self-assigned this Oct 19, 2023
@ndcunningham ndcunningham requested review from a team as code owners October 19, 2023 16:05
@ndcunningham ndcunningham requested a review from jaysoo October 19, 2023 16:05
@vercel
Copy link

vercel bot commented Oct 19, 2023

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

1 Ignored Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Oct 20, 2023 3:39pm

@Coly010
Copy link
Contributor

Coly010 commented Oct 19, 2023

I feel like instead of a try catch, we could just use an if statement to check if the project exists in the graph.

if it does, continue, if it doesn’t, log a warning, but continue execution with the next remote?

Cc @jaysoo

@ndcunningham ndcunningham force-pushed the fix/error-message-invalid-remote branch from 9d32017 to 0484843 Compare October 19, 2023 18:07
@ndcunningham ndcunningham force-pushed the fix/error-message-invalid-remote branch from 0484843 to 1b03ef4 Compare October 19, 2023 18:22
@ndcunningham ndcunningham enabled auto-merge (squash) October 19, 2023 18:23
@ndcunningham ndcunningham force-pushed the fix/error-message-invalid-remote branch from 1b03ef4 to 58ee114 Compare October 20, 2023 15:38
@ndcunningham ndcunningham requested a review from a team as a code owner October 20, 2023 15:38
@ndcunningham ndcunningham merged commit 022f1ea into nrwl:master Oct 23, 2023
2 checks passed
@ndcunningham ndcunningham deleted the fix/error-message-invalid-remote branch October 23, 2023 16:06
FrozenPandaz pushed a commit that referenced this pull request Oct 25, 2023
@github-actions
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 Oct 29, 2023
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.

4 participants