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(misc): ensure plugins are not creating workspace context while creating nodes #22967

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AgentEnder
Copy link
Member

…eating nodes

Current Behavior

Some plugins utilize globWithWorkspaceContext to perform a glob search during createNodes. This works fine without plugin isolation, and would still "work" with it, but when plugins are isolated they don't share a workspace context. Combine this with the daemon and we have issues.

  • Isolated plugin's workspace context is not updated by file updates, meaning glob searches can return deleted files
  • The workspace context has to be created multiple times, potentially resulting in slow FS times as the trees are traversed.

Expected Behavior

If the daemon is enabled, its workspace context is utilized when performing glob searches

Related Issue(s)

Fixes #

@AgentEnder AgentEnder requested review from a team as code owners April 23, 2024 21:43
Copy link

vercel bot commented Apr 23, 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 Apr 23, 2024 9:55pm

Copy link
Collaborator

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

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

Playwright is actually also broken.. but would be fixed if you convert all the functions in the WorkspaceContext to go to the daemon.

None of the calls to the workspace context should stay on the process unless the daemon is disabled or its on the daemon itself. Things like the Nx process should also go to the daemon to not do double work.


const DAEMON_ENV_SETTINGS = {
NX_PROJECT_GLOB_CACHE: 'false',
NX_CACHE_PROJECTS_CONFIG: 'false',

// Used to identify that the code is running in the daemon process.
NX_ON_DAEMON_PROCESS: 'true',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can set a global.NX_DAEMON = true on the Daemon Server

Comment on lines +11 to +17
export async function globAsync(globs: string[], exclude?: string[]) {
if (isOnDaemon() || !daemonClient.enabled()) {
return globWithWorkspaceContext(workspaceRoot, globs, exclude);
} else {
return daemonClient.glob(globs, exclude);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can do this in the workspace-context.ts file.

Those functions should actually all go to the daemon...

Things like allWorkspaceFiles are also broken right now.

Could we change them all?

Comment on lines +1 to +3
export function isOnDaemon() {
return !!process.env.NX_ON_DAEMON_PROCESS;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably live in the daemon directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants