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 reset --only-workspace-data (nx 9.2.x - 9.5.1) => Failed to reset the Nx workspace #27006

Closed
1 of 4 tasks
omishyn-dm opened this issue Jul 19, 2024 · 20 comments
Closed
1 of 4 tasks
Assignees
Labels
scope: core core nx functionality type: bug

Comments

@omishyn-dm
Copy link

Current Behavior

Resetting:

  • Workspace data directory

NX Failed to reset the Nx workspace.

Failed to clean up the workspace data directory.

Expected Behavior

nx reset

NX Resetting the Nx workspace cache and stopping the Nx Daemon.

This might take a few minutes.

NX Daemon Server - Stopped

NX Successfully reset the Nx workspace.

GitHub Repo

No response

Steps to Reproduce

  1. create angular app with nx 9.1.2
  2. nx build app
  3. nx reset
  4. nx migrate @nx@latest
  5. nx build app
  6. nx reset

Nx Report

Node   : 20.11.1
OS     : win32-x64
npm    : 9.7.2

nx (global)        : 19.1.2
nx                 : 19.5.1
@nx/js             : 19.5.1
@nx/jest           : 19.5.1
@nx/linter         : 19.5.1
@nx/eslint         : 19.5.1
@nx/workspace      : 19.5.1
@nx/angular        : 19.5.1
@nx/cypress        : 19.5.1
@nx/devkit         : 19.5.1
@nx/eslint-plugin  : 19.5.1
@nx/plugin         : 19.5.1
@nrwl/tao          : 19.5.1
@nx/web            : 19.5.1
@nx/webpack        : 19.5.1
typescript         : 5.5.3
---------------------------------------
Community plugins:
@compodoc/compodoc   : 1.1.19
@ngneat/spectator    : 6.1.3
@ngrx/effects        : 18.0.1
@ngrx/router-store   : 18.0.1
@ngrx/schematics     : 18.0.1
@ngrx/store          : 18.0.1
@ngrx/store-devtools : 18.0.1
ngx-build-plus       : 16.0.0
---------------------------------------
⚠️ Unable to construct project graph.
EPERM: operation not permitted, open 'D:\proj_dm\3_adfree\00_18_nf\servers\gui\adfree\.nx\workspace-data\d\daemon.log'
Error: EPERM: operation not permitted, open 'D:\proj_dm\3_adfree\00_18_nf\servers\gui\adfree\.nx\workspace-data\d\daemon.log'
    at Object.writeFileSync (node:fs:2352:20)
    at createFileSync (D:\proj_dm\3_adfree\00_18_nf\servers\gui\adfree\node_modules\nx\node_modules\fs-extra\lib\ensure\file.js:60:6)
    at DaemonClient.startInBackground (D:\proj_dm\3_adfree\00_18_nf\servers\gui\adfree\node_modules\nx\src\daemon\client\client.js:363:39)
    at DaemonClient.sendMessageToDaemon (D:\proj_dm\3_adfree\00_18_nf\servers\gui\adfree\node_modules\nx\src\daemon\client\client.js:316:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async D:\proj_dm\3_adfree\00_18_nf\servers\gui\adfree\node_modules\nx\src\utils\promised-based-queue.js:19:21

Failure Logs

No response

Package Manager Version

npm --version 9.7.2

Operating System

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

Additional Information

nx 9.5.1
no_security

nx 9.1.2
with_security

@LightBulbIdea
Copy link

I am also experiencing this issue with Nx version 19.5.1.

image

After running that command in VS Code I can't do anything else but close VS Code via the Task Manager so I can start using npx commands again.

image

This is what I get when I try open the file that is locking VS Code from doing anything.
image

I am an admin on this computer. So permissions is not an issue. I also have another Angular app running on Nx version 19.3.0 and I am not getting this error.

@dadfarjs
Copy link

dadfarjs commented Jul 20, 2024

End task all processes "Node.js" OR "VSCode" OR "Git" in Task Manager

@LightBulbIdea
Copy link

LightBulbIdea commented Jul 20, 2024

@dadfarjs Is that the solution? Why is this happening in the first place?

To your point, it works again after killing all VS Code instances via the Task Manager. But the second you run "npx nx reset" it glitches again.

@instantgis
Copy link

I am also experiencing this issue with Nx 9.5.1. I tried downgrading to 9.5.0 the lowest version that supports Angular 18 and is not beta. Same thing. This is a show stopper for me just at the time that I wanted to migrate to Nx. My bad luck. Hopefully this gets resolved quickly.

@dadfarjs
Copy link

@dadfarjs Is that the solution? Why is this happening in the first place?

To your point, it works again after killing all VS Code instances via the Task Manager. But the second you run "npx nx reset" it glitches again.

If there is a problem in one of the programs of your project and the "nx serve app-name" command is executed. This information will be placed in the workspace.
At first, the problem in the program should be resolved and all node.js and vscode processes should be the end task.
Then run "nx reset".
I haven't found a better way yet

You can use this command to see the program's problems in the terminal output:
nx g @nx/workspace:fix-configuration
OR
nx g @nx/workspace:fix-configuration --verbose

@omishyn-dm
Copy link
Author

I checked nx by versions
19.1.2, 19.2.3, 19.3.2, 19.4.4 - worked good
19.5.0, 19.5.1 - Failed to reset the Nx workspace

@Veskel01
Copy link

I have the same problem. Unfortunately - this is another bug that makes work terribly unpleasant. It has been practically constant for some time. I hope Team NX will improve the flow of releasing new versions, because it is getting worse and worse

@FrozenPandaz FrozenPandaz added the scope: core core nx functionality label Jul 22, 2024
@MaxKless
Copy link
Collaborator

Hey! It might be a bug in Nx Console, the vscode extension. Can you close all instances of vscode & make sure processes are dead.
Then run an nx command & nx reset in the terminal.
Is the behaviour the same? Is the daemon.log file still locked?

@omishyn-dm
Copy link
Author

I checked witout any IDE, only from cmd

npx create-nx-workspace myng
cd myng
npx nx build
npx nx reset

image
image

Failed to reset the Nx workspace.

@omishyn-dm
Copy link
Author

image
nx report

NX Report complete - copy this into the issue template

Node : 20.15.1
OS : win32-x64
npm : 10.7.0

nx (global) : 19.4.4
nx : 19.5.2
@nx/js : 19.5.2
@nx/jest : 19.5.2
@nx/linter : 19.5.2
@nx/eslint : 19.5.2
@nx/workspace : 19.5.2
@nx/angular : 19.5.2
@nx/devkit : 19.5.2
@nx/eslint-plugin : 19.5.2
@nrwl/tao : 19.5.2
@nx/web : 19.5.2
@nx/webpack : 19.5.2
typescript : 5.5.4

⚠️ Unable to construct project graph.
EPERM: operation not permitted, open 'D:\proj_nx\myng.nx\workspace-data\d\daemon.log'
Error: EPERM: operation not permitted, open 'D:\proj_nx\myng.nx\workspace-data\d\daemon.log'
at Object.writeFileSync (node:fs:2368:20)
at createFileSync (D:\proj_nx\myng\node_modules\nx\node_modules\fs-extra\lib\ensure\file.js:60:6)
at DaemonClient.startInBackground (D:\proj_nx\myng\node_modules\nx\src\daemon\client\client.js:363:39)
at DaemonClient.sendMessageToDaemon (D:\proj_nx\myng\node_modules\nx\src\daemon\client\client.js:316:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async D:\proj_nx\myng\node_modules\nx\src\utils\promised-based-queue.js:19:21

@mr-dugr
Copy link

mr-dugr commented Jul 24, 2024

I did some digging in the codebase and PRs introduced between versions 19.4.4 (that works ok) and 19.5.0 and it seems that the problem is with this PR: #26888
Don't see any description of that feature in the PR, but it enables plugin isolation by default in 19.5.0+ versions and causes the issue described by @omishyn-dm .

Also, checking Task Manager processes you can see that there are extra 4 node processes started and not killed after running e.g. npx nx report command (4x node.exe with cmd ...\node_modules\nx\src\project-graph\plugins\isolation\plugin-worker ...) and only killing them gives back access to debug.log file and running again 'npx nx reset' or any other nx command.

Setting env variable mentioned in the PR to false makes all work ok again, i.e. setting NX_ISOLATE_PLUGINS=false e.g. in .env file of your repo.

So either that PR should be reverted and previous default for plugin isolation used (i.e. not to use that plugin isolation), or there is a need of fixing internal logic of plugin isolation feature that currently makes versions 19.5.0+ completely unusable (at least on Windows).

@henke443
Copy link

I also experienced this issue on 19.5.2

@henke443
Copy link

henke443 commented Jul 24, 2024

Error: EPERM: operation not permitted, open 'C:\Users\henke\Documents\prog\...\.nx\workspace-data\d\daemon.log'
Restarting the computer kills the daemon so that I can delete the file, but weirdly when running both nx daemon and pnpm nx daemon while the issue is occurring they say that the dameon is not running

@mfundoshabalala
Copy link

I encountered the same issue, but I managed to resolve it by following these steps:

  • Navigate to the workspace root directory.
  • Ensure that all running processes, including nx serve, are stopped.

After performing these steps, the issue was resolved.

@MaxKless
Copy link
Collaborator

Thanks everyone for helping out and investigating here. The issue seems to be plugin isolation. We now spawn an isolated worker process for each plugin during project graph creation.
Something is going on on windows which is leading to some of those plugin instances not being shut down properly as they should on windows.
We're investigating further, if anyone has any more insights feel free to share them. The relevant code should be somewhere around here packages/nx/src/project-graph/plugins/isolation/plugin-pool.ts or in plugin-worker.ts

@MaxKless
Copy link
Collaborator

While there's still no fix: you can disable plugin isolation for now using NX_ISOLATE_PLUGINS=false and it should work again while we find a proper fix. @omishyn-dm @henke443 @mfundoshabalala @instantgis

@MaxKless
Copy link
Collaborator

hey everyone! Just wanted to let you know that we've disabled plugin isolation on windows by default with 19.5.4 until we find a proper fix for this issue :)

@omishyn-dm
Copy link
Author

Thank you, 19.5.4 works!

@beaussan
Copy link
Contributor

beaussan commented Aug 1, 2024

Hey @MaxKless, I wanted to chime in, I have the same issue on Mac so it's not only related to widows. Disabling plugin isolation fixes the issue also on my side.

I have both local nx plugins (aka ts files in the repo, referenced with a path in nx.json) and plugins loaded via npm (@nx/vite/plugin for ex)

Let me know if there is some way I can help on this issue

Edit: I found a similar issue, probably related : #27040

@AgentEnder
Copy link
Member

This should be fixed by #27317, which was just merged. A new canary will go out tonight, if a few folks could try it and make sure things are working that would be appreciated.

I'm going to preemptively close this out since the PR has been merged. If it is still broken, please let us know here or by opening a new issue. Thanks for the cooperation everyone :)

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