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

Error start remotes Nx 19.1.0 #26169

Closed
1 of 4 tasks
AlanGRutter opened this issue May 28, 2024 · 4 comments · Fixed by #26320
Closed
1 of 4 tasks

Error start remotes Nx 19.1.0 #26169

AlanGRutter opened this issue May 28, 2024 · 4 comments · Fixed by #26320
Assignees
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@AlanGRutter
Copy link

Current Behavior

After upgrading and migrating Nx to 19.1.0, when I try to start my module federated host application using nx serve, I get a TypeError as shown in the failure logs.

If I use the command nx serve and specify --devRemotes, it works without any problems.

Expected Behavior

The host app should be served correctly without errors.

GitHub Repo

No response

Steps to Reproduce

  1. I don't have a repo in which to reproduce.

Nx Report

Node   : 20.12.2
OS     : linux-x64
yarn   : 4.2.2

nx (global)        : 19.1.0
nx                 : 19.1.0
@nx/js             : 19.1.0
@nx/jest           : 19.1.0
@nx/linter         : 19.1.0
@nx/eslint         : 19.1.0
@nx/workspace      : 19.1.0
@nx/angular        : 19.1.0
@nx/cypress        : 19.1.0
@nx/devkit         : 19.1.0
@nx/eslint-plugin  : 19.1.0
@nx/storybook      : 19.1.0
@nrwl/tao          : 19.1.0
@nx/web            : 19.1.0
@nx/webpack        : 19.1.0
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/cypress/plugin
@nx/eslint/plugin
@nx/storybook/plugin
---------------------------------------
Community plugins:
@nx-tools/nx-container                : 6.0.1
@storybook/angular                    : 8.1.4
@syncfusion/ej2-angular-base          : 25.2.6
@syncfusion/ej2-angular-buttons       : 25.2.6
@syncfusion/ej2-angular-inputs        : 25.2.6
@syncfusion/ej2-angular-notifications : 25.2.3
ngxtension                            : 3.3.0

Failure Logs

nx serve web --no-cloud --verbose
[NX CLOUD] Verifying current cloud bundle
[NX CLOUD] Currently installed bundle is invalid, downloading version 2405.23.7.hotfix3  from  https://cloud.nx.app/nx-cloud/static/client-bundle
[NX CLOUD] Done:  /home/alan.rutter/TAGTheAgency/YES/YoungEnterpriseV2/yes-web-portal/.nx/cache/cloud/2405.23.7.hotfix3

 NX   Nx Cloud Manually Disabled

Nx will continue running, but nothing will be written or read from the remote cache.
Run details will also not be available in the Nx Cloud UI.

If this wasn't intentional, check for the NX_NO_CLOUD environment variable, the --no-cloud flag


> nx run web:serve:development


 NX  Starting module federation dev-server for web with 1 remotes


 NX   Cannot read properties of undefined (reading 'find')


TypeError: Cannot read properties of undefined (reading 'find')
    at startRemotes (/home/alan.rutter/TAGTheAgency/YES/YoungEnterpriseV2/yes-web-portal/node_modules/@nx/angular/src/executors/module-federation-dev-server/lib/start-dev-remotes.js:16:58)
    at moduleFederationDevServerExecutor (/home/alan.rutter/TAGTheAgency/YES/YoungEnterpriseV2/yes-web-portal/node_modules/@nx/angular/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js:81:61)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at getLastValueFromAsyncIterableIterator (/home/alan.rutter/TAGTheAgency/YES/YoungEnterpriseV2/yes-web-portal/node_modules/nx/src/utils/async-iterator.js:15:19)
    at iteratorToProcessStatusCode (/home/alan.rutter/TAGTheAgency/YES/YoungEnterpriseV2/yes-web-portal/node_modules/nx/src/command-line/run/run.js:44:29)
    at handleErrors (/home/alan.rutter/TAGTheAgency/YES/YoungEnterpriseV2/yes-web-portal/node_modules/nx/src/utils/params.js:10:16)
    at process.<anonymous> (/home/alan.rutter/TAGTheAgency/YES/YoungEnterpriseV2/yes-web-portal/node_modules/nx/bin/run-executor.js:59:28)

————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Running target serve for project web failed

Failed tasks:

- web:serve:development

Hint: run the command with --verbose for more details.

Package Manager Version

No response

Operating System

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

Additional Information

No response

@rternavskyi
Copy link

I have same problem!

@MaxSassen
Copy link

MaxSassen commented May 30, 2024

same issue when migrating to 19

OS     : darwin-x64
npm    : 10.2.4

nx (global)        : 18.0.8
nx                 : 19.1.1
@nx/js             : 19.1.1
@nx/jest           : 19.1.1
@nx/linter         : 19.1.1
@nx/eslint         : 19.1.1
@nx/workspace      : 19.1.1
@nx/angular        : 19.1.1
@nx/cypress        : 19.1.1
@nx/devkit         : 19.1.1
@nx/eslint-plugin  : 19.1.1
@nx/nest           : 19.1.1
@nx/node           : 19.1.1
@nx/playwright     : 19.1.1
@nx/plugin         : 19.1.1
@nrwl/tao          : 19.1.1
@nx/web            : 19.1.1
@nx/webpack        : 19.1.1
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/playwright/plugin
---------------------------------------
Community plugins:
@compodoc/compodoc : 1.1.23
@ngneat/input-mask : 6.1.0
@nx-go/nx-go       : 2.8.0
apollo-angular     : 6.0.0

had a deeper dive into the issue, I think the change regarding overwrite remote config (mfe) causes this issue.
When running the MFE config (without devRemotes) like:

 const config: ModuleFederationConfig = {
  name: 'platform-fe',
  remotes: ['fe-3', 'fe-2'],
  shared: sharedModuleFederationConfig,
};

error:

TypeError: Cannot read properties of undefined (reading 'find')
    at startRemotes (/Users/###/Projects/###/node_modules/@nx/angular/src/executors/module-federation-dev-server/lib/start-dev-remotes.js:16:58)

solved with:
fix in the start-dev-remotes.js (dirty fix to have this work)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startRemotes = void 0;
const devkit_1 = require("@nx/devkit");
async function startRemotes(remotes, workspaceProjects, options, context, target = 'serve') {
    const remoteIters = [];
    for (const app of remotes) {
        if (!workspaceProjects[app].targets?.[target]) {
            throw new Error(`Could not find "${target}" target in "${app}" project.`);
        }
        else if (!workspaceProjects[app].targets?.[target].executor) {
            throw new Error(`Could not find executor for "${target}" target in "${app}" project.`);
        }
        const [collection, executor] = workspaceProjects[app].targets[target].executor.split(':');
        const isUsingModuleFederationDevServerExecutor = executor.includes('module-federation-dev-server');
        const configurationOverride = options.devRemotes?.find((r) => typeof r !== 'string' && r.remoteName === app)?.configuration;
        remoteIters.push(await (0, devkit_1.runExecutor)({
            project: app,
            target,
            configuration: configurationOverride ?? context.configurationName,
        }, {
            ...(target === 'serve' ? { verbose: options.verbose ?? false } : {}),
            ...(isUsingModuleFederationDevServerExecutor
                ? { isInitialHost: false }
                : {}),
        }, context));
    }
    return remoteIters;
}
exports.startRemotes = startRemotes;

changed: options.devRemotes?.find. (make it non required)

got a PR: #26265

@leosvelperez leosvelperez added the scope: angular Issues related to Angular support in Nx label Jun 3, 2024
@leosvelperez leosvelperez self-assigned this Jun 3, 2024
leosvelperez added a commit that referenced this issue Jun 3, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

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

Fixes #26169
@MaxSassen
Copy link

@leosvelperez thanks !

FrozenPandaz pushed a commit that referenced this issue Jun 3, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

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

Fixes #26169

(cherry picked from commit ccd16b1)
Copy link

github-actions bot commented Jul 6, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants