nx icon indicating copy to clipboard operation
nx copied to clipboard

Slow project graph calculation with bun

Open rosslo opened this issue 5 months ago • 3 comments

Current Behavior

I was previously using [email protected] and noticed that it does not parse externalNodes when inspecting the .nx/workspace-data/project-graph.json file.

To address this, I attempted to upgrade to [email protected] to see if the new version resolves this issue.

While externalNodes parsing works correctly in [email protected], I am now experiencing extremely slow project graph calculations. It takes approximately 10 minutes to complete.

When running an Nx task, I see the following log message:

⠙ Calculating the project graph on the Nx Daemon is taking longer than expected. Re-run with NX_DAEMON=false to see more details.

And the following is .nx/workspace-data/d/daemon.log:

[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:51:25.505Z - Started listening on: /var/folders/k3/p73n85qx2bv2qhft425zd4cc0000gn/T/794c3a57da334cf7bfaa/d.sock
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:51:25.514Z - [WATCHER]: Subscribed to changes within: /Users/user/Documents/repo (native)
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:51:25.515Z - Established a connection. Number of open connections: 1
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:51:25.516Z - Established a connection. Number of open connections: 2
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:51:25.517Z - Closed a connection. Number of open connections: 1
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:51:25.521Z - [REQUEST]: Client Request for Project Graph Received
Time for 'plugin worker 22522 code loading' 7.648125
Time for 'plugin worker 22523 code loading' 7.727083999999998
Time for 'plugin worker 22524 code loading' 26.829417
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:51:25.748Z - Time taken for 'Load Nx Plugin: /Users/user/Documents/repo/node_modules/nx/src/plugins/package-json' 225.86283399999996ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:51:25.753Z - Time taken for 'Load Nx Plugin: /Users/user/Documents/repo/node_modules/nx/src/plugins/js' 230.92508299999997ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:51:27.366Z - Time taken for 'loadDefaultNxPlugins' 239.31599999999997ms
Time for 'nx/core/project-json:createNodes' 10.915542000000187
Time for 'nx/core/package-json:createNodes' 43.82349999999997
Creating project graph nodes with 3 plugins
Time for 'nx/js/dependencies-and-lockfile:createNodes' 161971.683292
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:54:09.375Z - Time taken for 'build-project-configs' 162014.86258400002ms
Time for 'plugin worker 22729 code loading' 3.869583000000002
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:54:10.042Z - [REQUEST]: Updated workspace context based on watched changes, recomputing project graph...
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:54:10.042Z - [REQUEST]: 
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:54:10.042Z - [REQUEST]: 
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:54:10.053Z - No files changed, but no in-memory cached project graph found. Recomputing it...
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:54:10.059Z - Time taken for 'loadSpecifiedNxPlugins' 164512.03025ms
Time for 'nx/core/project-json:createNodes' 5.639083000016399
Time for 'repo-nx-plugin:createNodes' 16.64949999999999
Time for 'nx/core/package-json:createNodes' 14.34350000001723
Creating project graph nodes with 4 plugins
Time for 'nx/js/dependencies-and-lockfile:createNodes' 134032.159542
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T08:56:24.229Z - Time taken for 'build-project-configs' 134063.310542ms
Creating project graph dependencies with 4 plugins
DEBUG nx::native::plugins::js::ts_import_locators: /Users/user/Documents/repo/apps/ft-ui/src/shared/components/Select.tsx:42:11 Unexpected token. Did you mean `{'>'}` or `>`?
DEBUG nx::native::plugins::js::ts_import_locators: /Users/user/Documents/repo/apps/ft-ui/src/shared/components/Select.tsx:43:8 Unexpected token. Did you mean `{'}'}` or `}`?
DEBUG nx::native::plugins::js::ts_import_locators: /Users/user/Documents/repo/apps/ft-ui/src/shared/components/Select.tsx:44:6 Unexpected token. Did you mean `{'>'}` or `>`?
DEBUG nx::native::plugins::js::ts_import_locators: /Users/user/Documents/repo/libs/ck/src/ck/Tabs.tsx:32:80 Unexpected token. Did you mean `{'>'}` or `>`?
DEBUG nx::native::plugins::js::ts_import_locators: /Users/user/Documents/repo/libs/ck/src/ck/Select.tsx:18:84 Unexpected token. Did you mean `{'>'}` or `>`?
DEBUG nx::native::plugins::js::ts_import_locators: /Users/user/Documents/repo/libs/ck/src/ck/Time:76:4 Unexpected token. Did you mean `{'>'}` or `>`?
DEBUG nx::native::plugins::js::ts_import_locators: /Users/user/Documents/repo/libs/ck/src/ck/Time:102:63 Unexpected token. Did you mean `{'>'}` or `>`?
DEBUG nx::native::plugins::js::ts_import_locators: /Users/user/Documents/repo/apps/us-ui/src/pages/components/Select.tsx:18:102 Unexpected token. Did you mean `{'>'}` or `>`?
DEBUG nx::native::plugins::js::ts_import_locators: /Users/user/Documents/repo/apps/us-ui/src/utils/Input.js:4:19 Invalid character in identifier
DEBUG nx::native::plugins::js::ts_import_locators: /Users/user/Documents/repo/libs/ck/src/components/NewMenu/Menu.tsx:14:84 Unexpected token. Did you mean `{'>'}` or `>`?
...ignore other DEBUG lines, they are the same errors...


Time for 'build typescript dependencies' 7574.228792000038
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.559Z - Wrote project graph cache to /Users/user/Documents/repo/.nx/workspace-data/project-graph.json
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.559Z - [SYNC]: collect registered sync generators
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.563Z - [SYNC]: scheduling: ["@nx/js:typescript-sync"]
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.563Z - [REQUEST]: Responding to the client. project-graph
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.565Z - Time taken for 'total for creating and serializing project graph' 527011.70325ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.571Z - Done responding to the client project-graph
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.571Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 527042. Response time: 8.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.592Z - [REQUEST]: Responding to the client. handleRunPreTasksExecution
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.592Z - Done responding to the client handleRunPreTasksExecution
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.592Z - Handled PRE_TASKS_EXECUTION. Handling time: 1. Response time: 0.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.592Z - Time taken for 'preTasksExecution' 0.3755419999361038ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.664Z - [SYNC]: running scheduled generator @nx/js:typescript-sync
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.808Z - Reusing in-memory cached project graph because no files changed.
DEBUG nx::native::tasks::task_hasher: plan length: 1
DEBUG nx::native::tasks::hashers::hash_workspace_files: Hashing workspace fileset{cache_key="nx.json,.gitignore,.nxignore"}: Adding "18382656446699850397" (".gitignore") to hash
DEBUG nx::native::tasks::hashers::hash_workspace_files: Hashing workspace fileset{cache_key="nx.json,.gitignore,.nxignore"}: Adding "7547700686801984408" (".nxignore") to hash
DEBUG nx::native::tasks::hashers::hash_workspace_files: Hashing workspace fileset{cache_key="nx.json,.gitignore,.nxignore"}: Adding "8779097934717182721" ("nx.json") to hash
DEBUG nx::native::tasks::hashers::hash_workspace_files: Hashing workspace fileset{cache_key="nx.json,.gitignore,.nxignore"}: Hash Value: "14741452919122330472"
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.829Z - [REQUEST]: Responding to the client. handleHashTasks
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.829Z - Done responding to the client handleHashTasks
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.829Z - Handled HASH_TASKS. Handling time: 21. Response time: 0.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.832Z - Established a connection. Number of open connections: 2
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.832Z - Established a connection. Number of open connections: 3
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.833Z - Closed a connection. Number of open connections: 2
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.837Z - [REQUEST]: Client Request for Project Graph Received
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.837Z - Reusing in-memory cached project graph because no files changed.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.837Z - [REQUEST]: Responding to the client. project-graph
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.838Z - Time taken for 'total for creating and serializing project graph' 0.3467919999966398ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.847Z - Done responding to the client project-graph
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:12.847Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 0. Response time: 10.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.456Z - [SYNC]: @nx/js:typescript-sync changes: 
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.456Z - Time taken for 'run-sync-generator:@nx/js:typescript-sync' 791.4948749999749ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.486Z - [REQUEST]: Responding to the client. handleGetEstimatedTaskTimings
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.486Z - Done responding to the client handleGetEstimatedTaskTimings
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.486Z - Handled GET_ESTIMATED_TASK_TIMINGS. Handling time: 26. Response time: 0.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.740Z - Established a connection. Number of open connections: 3
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.740Z - Closed a connection. Number of open connections: 2
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.741Z - Established a connection. Number of open connections: 3
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.746Z - [REQUEST]: Client Request for Project Graph Received
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.746Z - Reusing in-memory cached project graph because no files changed.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.746Z - [REQUEST]: Responding to the client. project-graph
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.747Z - Time taken for 'total for creating and serializing project graph' 0.2971250000409782ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.752Z - Done responding to the client project-graph
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.752Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 0. Response time: 6.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.780Z - Closed a connection. Number of open connections: 2
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.842Z - [WATCHER]: Processing file changes in outputs
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.875Z - [WATCHER]: tools/bun-filter-generator/nx-graph-simplified.json was modified
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.984Z - [REQUEST]: Updated workspace context based on watched changes, recomputing project graph...
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.984Z - [REQUEST]: tools/bun-filter-generator/nx-graph-simplified.json
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.984Z - [REQUEST]: 
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:13.999Z - Time taken for 'hash changed files from watcher' 7.600458000088111ms
Time for 'repo-nx-plugin:createNodes' 7.4506669999682344
Time for 'nx/core/project-json:createNodes' 4.894915999961086
Time for 'nx/core/package-json:createNodes' 10.788582999957725
Time for 'nx/js/dependencies-and-lockfile:createNodes' 20.79762500000652
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.102Z - Time taken for 'build-project-configs' 39.296875ms
Time for 'build typescript dependencies' 0.02887499995995313
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.193Z - Wrote project graph cache to /Users/user/Documents/repo/.nx/workspace-data/project-graph.json
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.193Z - [SYNC]: collect registered sync generators
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.195Z - [SYNC]: project graph hash is the same, not collecting task sync generators
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.195Z - [SYNC]: nx.json hash is the same, not collecting global sync generators
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.195Z - [SYNC]: scheduling: ["@nx/js:typescript-sync"]
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.195Z - Time taken for 'total execution time for createProjectGraph()' 101.30320900003426ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.395Z - [SYNC]: running scheduled generator @nx/js:typescript-sync
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.399Z - [REQUEST]: Client Request for Project Graph Received
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.400Z - Reusing in-memory cached project graph because no files changed.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.400Z - [REQUEST]: Responding to the client. project-graph
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.401Z - Time taken for 'total for creating and serializing project graph' 0.3085410000057891ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.404Z - Done responding to the client project-graph
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.404Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 1. Response time: 4.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.874Z - [SYNC]: @nx/js:typescript-sync changes: 
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.874Z - Time taken for 'run-sync-generator:@nx/js:typescript-sync' 478.30354100000113ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.874Z - [WATCHER]: Processing file changes in outputs
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.878Z - [REQUEST]: Responding to the client. recordOutputsHash
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.878Z - Done responding to the client recordOutputsHash
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.878Z - Handled RECORD_OUTPUTS_HASH. Handling time: 0. Response time: 0.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.884Z - [REQUEST]: Responding to the client. handleRecordTaskRuns
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.884Z - Done responding to the client handleRecordTaskRuns
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.884Z - Handled RECORD_TASK_RUNS. Handling time: 0. Response time: 0.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.888Z - [REQUEST]: Responding to the client. handleGetFlakyTasks
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.889Z - Done responding to the client handleGetFlakyTasks
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:14.889Z - Handled GET_FLAKY_TASKS. Handling time: 0. Response time: 1.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:15.040Z - [REQUEST]: Responding to the client. handleRunPostTasksExecution
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:15.041Z - Done responding to the client handleRunPostTasksExecution
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:15.041Z - Handled POST_TASKS_EXECUTION. Handling time: 0. Response time: 1.
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:15.041Z - Time taken for 'postTasksExecution' 0.14720900007523596ms
[NX v21.4.0-beta.7 Daemon Server] - 2025-08-08T09:00:15.048Z - Closed a connection. Number of open connections: 1

Expected Behavior

Provide faster graph calculation with bun.

GitHub Repo

No response

Steps to Reproduce

Our repository contains 26 applications and 25 libraries. Additionally, we have numerous internal private packages, so I am unable to share the bun.lock file.

Nx Report

Node           : 20.19.0
OS             : darwin-arm64
Native Target  : aarch64-macos
bun            : 1.2.19

nx (global)    : 21.2.0
nx             : 21.4.0-beta.7
@nx/js         : 21.4.0-beta.7
@nx/jest       : 21.4.0-beta.7
@nx/eslint     : 21.4.0-beta.7
@nx/workspace  : 21.4.0-beta.7
@nx/devkit     : 21.4.0-beta.7
@nx/plugin     : 21.4.0-beta.7
typescript     : 5.7.3
---------------------------------------
Registered Plugins:
repo-nx-plugin
---------------------------------------
Local workspace plugins:
repo-nx-plugin
---------------------------------------
Cache Usage: 0.00 B / 92.64 GB

Failure Logs


Package Manager Version

No response

Operating System

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

Additional Information

No response

rosslo avatar Aug 08 '25 09:08 rosslo

Hi @leosvelperez , may I kindly inquire if there has been any progress on this issue?

rosslo avatar Nov 04 '25 08:11 rosslo

@rosslo I was able to workaround this problem by disabling lockfile analyze in the nx js plugin. There's an undocumented setting. From my nx.json:

  "pluginsConfig": {
      "@nx/js": {
          "analyzeLockfile": false
      }
  }

jmrossy avatar Dec 03 '25 18:12 jmrossy

Hey all! Some optimizations were merged and released in Nx v22.2.0. Please update to the latest version and try. Let me know how it goes.

leosvelperez avatar Dec 09 '25 12:12 leosvelperez

I'll close this for the time being, as some optimizations have been merged to improve the performance of the bun parser. We'll continue to look for further improvements as we conduct performance reviews on the entire process of graph creation.

leosvelperez avatar Dec 11 '25 11:12 leosvelperez