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 Daemon Server crashing when running pnpm install #23031

Open
4 tasks
lukeramsden opened this issue Apr 26, 2024 · 3 comments
Open
4 tasks

NX Daemon Server crashing when running pnpm install #23031

lukeramsden opened this issue Apr 26, 2024 · 3 comments
Assignees
Labels
scope: core core nx functionality type: bug

Comments

@lukeramsden
Copy link

lukeramsden commented Apr 26, 2024

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/nx@18.3.4_@swc+core@1.3.100_@swc+helpers@0.5.1_/node_modules/nx/src/daemon/server/server.js:203:90)
    at /<redacted>/ui/node_modules/.pnpm/nx@18.3.4_@swc+core@1.3.100_@swc+helpers@0.5.1_/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

  1. npx nx reset && npx nx daemon --start # start a clean daemon
  2. pnpm install # run install on an unchanged package.json and subsequently unchanged pnpm-lock.yaml
  3. 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

@AgentEnder AgentEnder added the scope: core core nx functionality label Apr 29, 2024
@creotip
Copy link

creotip commented Apr 30, 2024

Downgrade pnpm to v8, it will solve the issue

corepack use pnpm@latest-8

@Exponential-Workload
Copy link

Exponential-Workload commented Apr 30, 2024

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.

@Exponential-Workload
Copy link

Exponential-Workload commented Apr 30, 2024

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.

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: core core nx functionality type: bug
Projects
None yet
Development

No branches or pull requests

5 participants