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

feat(core): add daemon watcher filters #13229

Merged
merged 8 commits into from
Nov 19, 2022

Conversation

Cammisuli
Copy link
Member

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #

@vercel
Copy link

vercel bot commented Nov 17, 2022

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

Name Status Preview Updated
nx-dev ✅ Ready (Inspect) Visit Preview Nov 18, 2022 at 10:19PM (UTC)

@@ -71,14 +73,24 @@ export function addUpdatedAndDeletedFiles(
collectedDeletedFiles.add(f);
}

notifyFileWatcherSockets(null, updatedFiles, deletedFiles);
Copy link
Member

Choose a reason for hiding this comment

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

Only do it if you have updated or deleted files

cachedSerializedProjectGraphPromise =
processFilesAndCreateAndSerializeProjectGraph();
await cachedSerializedProjectGraphPromise;

notifyFileWatcherSockets(createdFiles, null, null);
Copy link
Member

Choose a reason for hiding this comment

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

Only do it if you have created files

return registeredFileWatcherSockets.length > 0;
}

export async function notifyFileWatcherSockets(
Copy link
Member

Choose a reason for hiding this comment

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

I'd remove "async". We invoke this function in the fire and forget fashion without awaiting. IntelliJ will actually complain that you invoke a function returning promise and not awaiting

return;
}

await queue.sendToQueue(async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Same: no await

})),
];

for (const changedFile of allChangedFiles) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you know how slow this can be? Imagine if reformated 1000 files in a big workspace.

Currently it's O(Number of changes files * Number of files)

I think a better way might be to create a map from files to projects. You complexity will change to O(Number of files + number of changed files)

@Cammisuli Cammisuli merged commit 3f2fa6c into nrwl:master Nov 19, 2022
@Cammisuli Cammisuli deleted the daemon_watcher_filter branch November 19, 2022 01:56
@github-actions
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 Mar 17, 2023
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.

None yet

2 participants