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

fix(core): copy native files to tmp file location instead of .nx/cache #23375

Merged
merged 1 commit into from
May 15, 2024

Conversation

MaxKless
Copy link
Collaborator

@MaxKless MaxKless commented May 14, 2024

Current Behavior

Currently, the .node files required to load native code are saved in .nx/cache. This can cause different issues:

  • users on windows sometimes experience errors during nx reset because it's trying to delete the entire folder and some process is still locking the file
  • @angular-eslint users are seeing the .nx/cache folder in their workspace since it uses @nx/devkit

Expected Behavior

We want no errors and for noone to be bothered by the .node file. This is why we move the .node file to a tmp location outside the workspace instead of .nx/cache. We still make sure to delete it during nx reset but throw no errors if that fails. It will simply be deleted by the next invocation of nx reset.

Related Issue(s)

Fixes #23224

@MaxKless MaxKless requested review from a team as code owners May 14, 2024 15:48
@MaxKless MaxKless requested a review from Cammisuli May 14, 2024 15:48
Copy link

vercel bot commented May 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview May 15, 2024 0:01am

@MaxKless MaxKless force-pushed the native-file-cache-tmp-folder branch from 3cc72a9 to 6c0038c Compare May 15, 2024 11:59
export const nativeFileCacheLocation = join(
tmpdir(),
'nx-native-file-cache',
createHash('sha256').update(workspaceRoot).digest('hex')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this nesting at all? Can't it be join(tmpdir(), 'nx/bin')?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to keep the same behaviour as before where the files are workspace-scoped. I'm not sure if there could be funky side-effects when one repo calls nx reset and deletes the .node file that is currently used by another process in another workspace.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay sounds good.

export const nativeFileCacheLocation = join(
tmpdir(),
'nx-native-file-cache',
createHash('sha256').update(workspaceRoot).digest('hex')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay sounds good.

@FrozenPandaz FrozenPandaz merged commit 5ce5337 into master May 15, 2024
6 checks passed
@FrozenPandaz FrozenPandaz deleted the native-file-cache-tmp-folder branch May 15, 2024 14:46
FrozenPandaz pushed a commit that referenced this pull request May 15, 2024
#23375)

## Current Behavior
Currently, the `.node` files required to load native code are saved in
`.nx/cache`. This can cause different issues:
- users on windows sometimes experience errors during `nx reset` because
it's trying to delete the entire folder and some process is still
locking the file
- `@angular-eslint` users are seeing the `.nx/cache` folder in their
workspace since it uses `@nx/devkit`

## Expected Behavior
We want no errors and for noone to be bothered by the `.node` file. This
is why we move the `.node` file to a tmp location outside the workspace
instead of `.nx/cache`. We still make sure to delete it during `nx
reset` but throw no errors if that fails. It will simply be deleted by
the next invocation of `nx reset`.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #23224

(cherry picked from commit 5ce5337)
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running nx reset on Windows results in an error when attempting to delete nx-win32-x64-msvc.node
3 participants