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

@nx/react module-federation e2e command fails with freshly generated remote application #30273

Open
1 of 4 tasks
oscar8880 opened this issue Mar 5, 2025 · 0 comments
Open
1 of 4 tasks

Comments

@oscar8880
Copy link

Current Behavior

When creating a fresh module-federated react app, the serve-static command fails for remote applications with a port issue. This in turn means the e2e command fails.

[WebServer] node:internal/validators:424
[WebServer]     throw new ERR_SOCKET_BAD_PORT(name, port, allowZero);
[WebServer]           ^
[WebServer] RangeError: Port should be >= 0 and < 65536. Received type number (-Infinity).
[WebServer]     at validatePort (node:internal/validators:424:11)
[WebServer]     at lookupAndConnect (node:net:1289:5)
[WebServer]     at Socket.connect (node:net:1246:5)
[WebServer]     at checkPort (/Users/ozealley/projects/nx-module-federation-issues/node_modules/@nx/web/src/utils/wait-for-port-open.js:40:20)
[WebServer]     at /Users/ozealley/projects/nx-module-federation-issues/node_modules/@nx/web/src/utils/wait-for-port-open.js:42:9
[WebServer]     at new Promise (<anonymous>)
[WebServer]     at waitForPortOpen (/Users/ozealley/projects/nx-module-federation-issues/node_modules/@nx/web/src/utils/wait-for-port-open.js:9:12)
[WebServer]     at /Users/ozealley/projects/nx-module-federation-issues/node_modules/@nx/rspack/src/executors/module-federation-static-server/module-federation-static-server.impl.js:214:101
[WebServer]     at Array.map (<anonymous>)
[WebServer]     at /Users/ozealley/projects/nx-module-federation-issues/node_modules/@nx/rspack/src/executors/module-federation-static-server/module-federation-static-server.impl.js:214:46 {
[WebServer]   code: 'ERR_SOCKET_BAD_PORT'
[WebServer] }
[WebServer] Node.js v20.10.0

Error: Process from config.webServer was not able to start. Exit code: 1

Expected Behavior

The serve-static command should build and serve the app locally so that the e2e step can test against it.

GitHub Repo

https://github.com/oscar8880/nx-module-federation-issues/tree/e2e-issue

Steps to Reproduce

  1. Clone https://github.com/oscar8880/nx-module-federation-issues/tree/e2e-issue
  2. Checkout branch e2e-issue
  3. npm install
  4. nx e2e shop-e2e or nx serve-static shop

To create the example I followed the docs here https://nx.dev/concepts/module-federation/faster-builds-with-module-federation. I'm using nx 20.4.6, node v20.10.0, npm 10.2.3.

  • npx create-nx-workspace nx-module-federation-issues --preset=apps
  • nx add @nx/react
  • nx g @nx/react:host apps/host --remotes=shop
  • No style choice
  • Playwright
  • RSPack
  • nx e2e shop-e2e

Nx Report

Node           : 20.10.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.2.3

nx                     : 20.4.6
@nx/js                 : 20.4.6
@nx/jest               : 20.4.6
@nx/eslint             : 20.4.6
@nx/workspace          : 20.4.6
@nx/devkit             : 20.4.6
@nx/eslint-plugin      : 20.4.6
@nx/module-federation  : 20.4.6
@nx/playwright         : 20.4.6
@nx/react              : 20.4.6
@nx/rspack             : 20.4.6
@nx/web                : 20.4.6
typescript             : 5.7.3

Failure Logs

> nx run shop:serve-static:production


 NX  Starting module federation dev-server for shop with 0 remotes


 NX  Built host


 NX  Starting static remotes proxies...


 NX  Static remotes proxies started successfully


 NX  Starting static host proxy...


 NX  Static host proxy started successfully

node:internal/validators:424
    throw new ERR_SOCKET_BAD_PORT(name, port, allowZero);
          ^

RangeError: Port should be >= 0 and < 65536. Received type number (-Infinity).
    at validatePort (node:internal/validators:424:11)
    at lookupAndConnect (node:net:1289:5)
    at Socket.connect (node:net:1246:5)
    at checkPort (/Users/ozealley/projects/nx-module-federation-issues/node_modules/@nx/web/src/utils/wait-for-port-open.js:40:20)
    at /Users/ozealley/projects/nx-module-federation-issues/node_modules/@nx/web/src/utils/wait-for-port-open.js:42:9
    at new Promise (<anonymous>)
    at waitForPortOpen (/Users/ozealley/projects/nx-module-federation-issues/node_modules/@nx/web/src/utils/wait-for-port-open.js:9:12)
    at /Users/ozealley/projects/nx-module-federation-issues/node_modules/@nx/rspack/src/executors/module-federation-static-server/module-federation-static-server.impl.js:214:101
    at Array.map (<anonymous>)
    at /Users/ozealley/projects/nx-module-federation-issues/node_modules/@nx/rspack/src/executors/module-federation-static-server/module-federation-static-server.impl.js:214:46 {
  code: 'ERR_SOCKET_BAD_PORT'
}

Node.js v20.10.0

Package Manager Version

No response

Operating System

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

Additional Information

No response

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

No branches or pull requests

1 participant