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): daemon file watcher #13068

Merged
merged 12 commits into from
Nov 11, 2022
Merged

Conversation

Cammisuli
Copy link
Member

@Cammisuli Cammisuli commented Nov 8, 2022

Co-authored-by: Victor Savkin vsavkin@users.noreply.github.com

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #

usage:

const { daemonClient } = require('nx/src/daemon/client/client.js');
daemonClient.registerFileWatcher(
  { project: [1] },
  (err, data) => {
     console.log(data)
  }
);

@vercel
Copy link

vercel bot commented Nov 8, 2022

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

1 Ignored Deployment
Name Status Preview Updated
nx-dev ⬜️ Ignored (Inspect) Nov 11, 2022 at 4:29PM (UTC)

@AgentEnder
Copy link
Member

Whats this one do?

Copy link
Member

@vsavkin vsavkin left a comment

Choose a reason for hiding this comment

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

Left a few small comments. Overall looks good.

) => void
): Promise<UnregisterCallback> {
await this.sendToDaemonViaQueue({ type: 'PING' });
let messenger = new SocketMessenger(connect(FULL_OS_SOCKET_PATH)).listen(
Copy link
Member

Choose a reason for hiding this comment

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

should be a const?

changedFiles.push({
path: event.path,
type: 'DELETE',
});
} else {
try {
const s = statSync(join(workspaceRoot, event.path));
if (!s.isDirectory()) {
Copy link
Member

Choose a reason for hiding this comment

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

I know it's unrelated but can we change it to s.isFile()

There are other things but directories and files. I think when I wrote this piece I missed it.

async function notifyFileWatcherSockets(
changedFiles: { path: string; type: 'CREATE' | 'UPDATE' | 'DELETE' }[]
) {
for (const { socket } of registeredFileWatcherSockets) {
Copy link
Member

Choose a reason for hiding this comment

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

Tecnically a faster thing would be to do:

await Promise.all(registeredFileWatcherSockets.map(socket => handleResult(socket...)))

It would then send data to all the sockets in parallel instead of sequentially.

Could you do that?

@Cammisuli Cammisuli merged commit a771dc9 into nrwl:master Nov 11, 2022
@Cammisuli Cammisuli deleted the daemon_multi_socket branch November 11, 2022 20:23
@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.

3 participants