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

"Maximum call stack size exceeded error" when running dev server using Nx webpack plugins and buildLibsFromSource #28006

Open
1 of 4 tasks
zoe-gonzales opened this issue Sep 19, 2024 · 0 comments · May be fixed by #29317
Open
1 of 4 tasks
Assignees
Labels
scope: react Issues related to React support for Nx type: bug

Comments

@zoe-gonzales
Copy link

zoe-gonzales commented Sep 19, 2024

Current Behavior

Hello, I'm working on updating an existing Nx app to leverage built projects in our webpack build with the buildLibsFromSource option. This app uses Nx webpack plugins (withNx, withReact) and the @nx/webpack executor.

I ran into the following error when running the serve target:

RangeError: Maximum call stack size exceeded
    at new FastBuffer (node:internal/buffer:960:14)
    at allocate (node:buffer:457:15)
    at Function.allocUnsafe (node:buffer:427:10)
    at tryCreateBuffer (node:fs:439:21)
    at Object.readFileSync (node:fs:482:14)
    at readFileSync (/Users/zgonzales/repro-dev-server-error/node_modules/tsconfig-paths/lib/tsconfig-loader.js:85:19)
    at loadTsconfig (/Users/zgonzales/repro-dev-server-error/node_modules/tsconfig-paths/lib/tsconfig-loader.js:90:24)
    at loadTsconfigFromExtends (/Users/zgonzales/repro-dev-server-error/node_modules/tsconfig-paths/lib/tsconfig-loader.js:134:18)
    at loadTsconfig (/Users/zgonzales/repro-dev-server-error/node_modules/tsconfig-paths/lib/tsconfig-loader.js:108:20)
    at loadTsconfigFromExtends (/Users/zgonzales/repro-dev-server-error/node_modules/tsconfig-paths/lib/tsconfig-loader.js:134:18)

I found that putting a breakpoint at node_modules/@nx/js/src/utils/buildable-libs-utils.js:119, there looks to be some unexpected behavior with the extends property of the temp tsconfig.generated.json file.

The first time the breakpoint is hit, extends field points to apps/repro-dev-server-error-app/tsconfig.app.json (I believe this is expected):
Screenshot 2024-09-19 at 3 19 50 PM

The second time the breakpoint is hit, extends points to tsconfig.generated.json:
Screenshot 2024-09-19 at 3 20 23 PM

The options that are used in this second call can be traced back to the options coming from withNx:

{ options, context }: NxWebpackExecutionContext

This is only an issue with dev server. Running a static build of webpack is successful.

Expected Behavior

The Webpack build succeeds when using Nx webpack plugins and setting buildLibsFromSource to false. In addition to using withNx and withReact, we've create custom plugins in our webpack config that follow this pattern. It would be great if we didn't have to refactor our config to use the basic plugins in order to disable buildLibsFromSource.

When the webpack config is changed to use the basic plugins as outlined on this page: https://nx.dev/recipes/webpack/webpack-config-setup, the error goes away.

The error also goes away when the webpack config is unchanged, but buildLibsFromSource is set to true.

GitHub Repo

https://github.com/zoe-gonzales/repro-dev-server-error/tree/main

Steps to Reproduce

  1. Clone repo and install dependencies
  2. Run npx nx serve repro-dev-server-error-app --verbose. The Maximum call stack size exceeded error should throw.

Nx Report

Node           : 18.17.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 9.6.7

nx                 : 19.7.4
@nx/js             : 19.7.4
@nx/jest           : 19.7.4
@nx/linter         : 19.7.4
@nx/eslint         : 19.7.4
@nx/workspace      : 19.7.4
@nx/devkit         : 19.7.4
@nx/eslint-plugin  : 19.7.4
@nx/react          : 19.7.4
@nrwl/tao          : 19.7.4
@nx/web            : 19.7.4
@nx/webpack        : 19.7.4
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

No response

@jaysoo jaysoo added the scope: react Issues related to React support for Nx label Sep 25, 2024
@xiongemi xiongemi linked a pull request Dec 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: react Issues related to React support for Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants