nx
nx copied to clipboard
NX Daemon Server crashing when running `pnpm install`
Current Behavior
Subsequent to #21492, we upgraded to 18.3.4 which contains the fix, and removed our hacky workaround where we call nx reset after running pnpm install due to the daemon server panicing in the Rust code.
We now see a different error:
[NX Daemon Server] - 2024-04-26T11:14:25.496Z - [WATCHER]: Unexpected workspace error Cannot read properties of null (reading 'message')
TypeError: Cannot read properties of null (reading 'message')
at handleWorkspaceChanges (/<redacted>/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/daemon/server/server.js:203:90)
at /<redacted>/ui/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/daemon/server/watcher.js:36:9
Expected Behavior
We would expect the daemon not to crash when running pnpm install
GitHub Repo
No response
Steps to Reproduce
- npx nx reset && npx nx daemon --start # start a clean daemon
- pnpm install # run install on an unchanged package.json and subsequently unchanged pnpm-lock.yaml
- Check daemon logs for the crash
Nx Report
NX Falling back to ts-node for local typescript execution. This may be a little slower.
- To fix this, ensure @swc-node/register and @swc/core have been installed
NX Report complete - copy this into the issue template
Node : 20.11.1
OS : linux-x64
pnpm : 9.0.2
nx : 18.3.4
@nx/js : 18.3.4
@nx/jest : 18.3.4
@nx/linter : 18.3.4
@nx/eslint : 18.3.4
@nx/workspace : 18.3.4
@nx/cypress : 18.3.4
@nx/devkit : 18.3.4
@nx/esbuild : 18.3.4
@nx/eslint-plugin : 18.3.4
@nx/node : 18.3.4
@nx/react : 18.3.4
@nx/rollup : 18.3.4
@nx/storybook : 18.3.4
@nrwl/tao : 18.3.4
@nx/web : 18.3.4
@nx/webpack : 18.3.4
typescript : 5.1.6
Failure Logs
No response
Package Manager Version
pnpm 9.0.2
Operating System
- [ ] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)
Additional Information
No response
Downgrade pnpm to v8, it will solve the issue
corepack use pnpm@latest-8
Downgrade pnpm to v8, it will solve the issue
corepack use pnpm@latest-8
This isn't a proper solution - pnpm 9 may be needed for certain projects (also, regressions shouldn't be solved by "just downgrade" - unless the maintainers of the affected software indicate that's the intended solution).
If the quoted text is intended as a workaround, rephrasing to will workaround would make the intent more clear :)
(edit: if the above came off as aggressive, that wasnt my intent, sorry abt that - idk how to phrase this in a more lighthearted way)
A possible solution would be to, wherever the relevant source code is (im just patching the output to get my setup working temporarily as a workaround whilst testing) use something like logger_1.serverLogger.watcherLog('Unexpected workspace watcher error', error?.message ?? error); instead of logger_1.serverLogger.watcherLog('Unexpected workspace watcher error', error.message); (or, on the line above that, do let error = err instanceof Error ? err : new Error(err) : err; rather than let error = typeof err === 'string' ? new Error(err) : err;).
Might submit a PR soon-ish if I feel like it.
Interestingly, in my short testing, replacing it with anything to get the value of err results in everything "just working"; no error being thrown by nx, even after running nx reset and trying again.
Interestingly, in my short testing, replacing it with anything to get the value of
errresults in everything "just working"; no error being thrown by nx, even after runningnx resetand trying again.
Update: found the root cause after a bit more messing around trying to get err outputted (i still dont know why it just randomly "worked" half the time when I tried to get it to output the value of it); err is null and the if block is getting triggered by the !changeEvents || !changeEvents.length, resulting in err not being an instance of a string (meaning the new Error doesn't get triggered) and the .message property being indexed.
~~Will submit a PR in a moment.~~ Nx tests fail both on master and with my commit, cba to figure them out right now - I'll leave the patch discussed in the last comment for someone else to make a PR for :)
Still see this on 19.0.3
[NX Daemon Server] - 2024-05-16T09:06:45.162Z - [WATCHER]: 2 file(s) created or restored, 5 file(s) modified, 0 file(s) deleted
[NX Daemon Server] - 2024-05-16T09:06:45.216Z - [WATCHER]: Unexpected workspace error Cannot read properties of null (reading 'message')
TypeError: Cannot read properties of null (reading 'message')
at handleWorkspaceChanges (<redacted>/ui/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/daemon/server/server.js:203:90)
at <redacted>/ui/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/daemon/server/watcher.js:36:9
[NX Daemon Server] - 2024-05-16T09:06:45.295Z - [REQUEST]: Updated workspace context based on watched changes, recomputing project graph...
[NX Daemon Server] - 2024-05-16T09:06:45.295Z - [REQUEST]: build/log/npx-console.log,build/log/profile_packageMonorepo.json,packages/protocols/fixplorer-protocol-types/src/lib/generated/index.ts,packages/protocols/trader-desktop-public-protocol-types/src/lib/generated/index.ts,packages/protocols/hds-public-protocol-types/src/lib/generated/index.ts,packages/protocols/websocket-session-public-protocol-types/src/lib/generated/index.ts,packages/protocols/feedback-protocol-types/src/lib/generated/index.ts
[NX Daemon Server] - 2024-05-16T09:06:45.296Z - [REQUEST]:
[NX Daemon Server] - 2024-05-16T09:06:45.495Z - [WATCHER]: Processing file changes in outputs
[NX Daemon Server] - 2024-05-16T09:06:45.499Z - Time taken for 'Load Nx Plugin: <redacted>/ui/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/plugins/project-json/build-nodes/package-json-next-to-project-json' 0.678927999921143ms
[NX Daemon Server] - 2024-05-16T09:07:44.456Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-05-16T09:07:44.460Z - Closed a connection. Number of open connections: 0
[NX Daemon Server] - 2024-05-16T09:07:44.466Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-05-16T09:07:44.466Z - [REQUEST]: Responding to the client with an error. File watcher error in the workspace '<redacted>/ui'. Cannot read properties of null (reading 'message')
TypeError: Cannot read properties of null (reading 'message')
at handleWorkspaceChanges (<redacted>/ui/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/daemon/server/server.js:203:90)
at <redacted>/ui/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/daemon/server/watcher.js:36:9
[NX Daemon Server] - 2024-05-16T09:07:44.467Z - Done responding to the client null
[NX Daemon Server] - 2024-05-16T09:07:44.474Z - [REQUEST]: Client Request for Project Graph Received
[NX Daemon Server] - 2024-05-16T09:07:44.476Z - [REQUEST]: Responding to the client. project-graph
[NX Daemon Server] - 2024-05-16T09:07:44.481Z - Time taken for 'total for creating and serializing project graph' 2.1216579996980727ms
[NX Daemon Server] - 2024-05-16T09:07:44.489Z - Socket error
Error: read ECONNRESET
at Pipe.onStreamRead (node:internal/stream_base_commons:217:20) {
errno: -104,
code: 'ECONNRESET',
syscall: 'read'
}
[NX Daemon Server] - 2024-05-16T09:07:44.492Z - Done responding to the client project-graph
[NX Daemon Server] - 2024-05-16T09:07:44.492Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 2. Response time: 16.
[NX Daemon Server] - 2024-05-16T09:07:44.499Z - Closed a connection. Number of open connections: 0
[NX Daemon Server] - 2024-05-16T09:07:44.599Z - [WATCHER]: Processing file changes in outputs
[NX Daemon Server] - 2024-05-16T09:07:44.611Z - [WATCHER]: Skipping handleWorkspaceChanges because of a previously recorded watcher error.
[NX Daemon Server] - 2024-05-16T09:08:53.586Z - [WATCHER]: Skipping handleWorkspaceChanges because of a previously recorded watcher error.
[NX Daemon Server] - 2024-05-16T09:08:53.586Z - [WATCHER]: Processing file changes in outputs
[NX Daemon Server] - 2024-05-16T09:09:18.825Z - [WATCHER]: Skipping handleWorkspaceChanges because of a previously recorded watcher error.
[NX Daemon Server] - 2024-05-16T09:09:18.826Z - [WATCHER]: Processing file changes in outputs
[NX Daemon Server] - 2024-05-16T09:09:22.555Z - [WATCHER]: Skipping handleWorkspaceChanges because of a previously recorded watcher error.
[NX Daemon Server] - 2024-05-16T09:09:22.555Z - [WATCHER]: Processing file changes in outputs
[NX Daemon Server] - 2024-05-16T09:09:23.184Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-05-16T09:09:23.186Z - Closed a connection. Number of open connections: 0
[NX Daemon Server] - 2024-05-16T09:09:23.187Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-05-16T09:09:23.189Z - [REQUEST]: Responding to the client with an error. File watcher error in the workspace '<redacted>/ui'. Cannot read properties of null (reading 'message')
TypeError: Cannot read properties of null (reading 'message')
at handleWorkspaceChanges (<redacted>/ui/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/daemon/server/server.js:203:90)
at <redacted>/ui/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/daemon/server/watcher.js:36:9
[NX Daemon Server] - 2024-05-16T09:09:23.189Z - Done responding to the client null
[NX Daemon Server] - 2024-05-16T09:09:23.190Z - [REQUEST]: Client Request for Project Graph Received
[NX Daemon Server] - 2024-05-16T09:09:23.191Z - [REQUEST]: Responding to the client. project-graph
[NX Daemon Server] - 2024-05-16T09:09:23.193Z - Time taken for 'total for creating and serializing project graph' 0.9973229998722672ms
[NX Daemon Server] - 2024-05-16T09:09:23.197Z - Socket error
Error: read ECONNRESET
at Pipe.onStreamRead (node:internal/stream_base_commons:217:20) {
errno: -104,
code: 'ECONNRESET',
syscall: 'read'
}
[NX Daemon Server] - 2024-05-16T09:09:23.197Z - Done responding to the client project-graph
[NX Daemon Server] - 2024-05-16T09:09:23.197Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 1. Response time: 6.
[NX Daemon Server] - 2024-05-16T09:09:23.197Z - Closed a connection. Number of open connections: 0
[NX Daemon Server] - 2024-05-16T09:09:23.259Z - [WATCHER]: Skipping handleWorkspaceChanges because of a previously recorded watcher error.
[NX Daemon Server] - 2024-05-16T09:09:23.259Z - [WATCHER]: Processing file changes in outputs
[NX Daemon Server] - 2024-05-16T09:12:40.325Z - [WATCHER]: Skipping handleWorkspaceChanges because of a previously recorded watcher error.
[NX Daemon Server] - 2024-05-16T09:12:40.325Z - [WATCHER]: Processing file changes in outputs
[NX Daemon Server] - 2024-05-16T09:13:07.416Z - [WATCHER]: Processing file changes in outputs
[NX Daemon Server] - 2024-05-16T09:13:07.426Z - [WATCHER]: Skipping handleWorkspaceChanges because of a previously recorded watcher error.
[NX Daemon Server] - 2024-05-16T09:13:10.900Z - [WATCHER]: Skipping handleWorkspaceChanges because of a previously recorded watcher error.
[NX Daemon Server] - 2024-05-16T09:13:10.900Z - [WATCHER]: Processing file changes in outputs
[NX Daemon Server] - 2024-05-16T09:13:11.661Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-05-16T09:13:11.664Z - Closed a connection. Number of open connections: 0
[NX Daemon Server] - 2024-05-16T09:13:11.666Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-05-16T09:13:11.668Z - [REQUEST]: Responding to the client with an error. File watcher error in the workspace '<redacted>/ui'. Cannot read properties of null (reading 'message')
TypeError: Cannot read properties of null (reading 'message')
at handleWorkspaceChanges (<redacted>/ui/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/daemon/server/server.js:203:90)
at <redacted>/ui/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_/node_modules/nx/src/daemon/server/watcher.js:36:9
[NX Daemon Server] - 2024-05-16T09:13:11.669Z - Done responding to the client null
[NX Daemon Server] - 2024-05-16T09:13:11.669Z - [REQUEST]: Client Request for Project Graph Received
[NX Daemon Server] - 2024-05-16T09:13:11.670Z - [REQUEST]: Responding to the client. project-graph
[NX Daemon Server] - 2024-05-16T09:13:11.678Z - Time taken for 'total for creating and serializing project graph' 1.195639000274241ms
[NX Daemon Server] - 2024-05-16T09:13:11.680Z - Socket error
Error: read ECONNRESET
at Pipe.onStreamRead (node:internal/stream_base_commons:217:20) {
errno: -104,
code: 'ECONNRESET',
syscall: 'read'
}
[NX Daemon Server] - 2024-05-16T09:13:11.681Z - Done responding to the client project-graph
[NX Daemon Server] - 2024-05-16T09:13:11.681Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 1. Response time: 11.
[NX Daemon Server] - 2024-05-16T09:13:11.681Z - Closed a connection. Number of open connections: 0
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.