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: do not watch .direnv and .devenv subdirectories #1733

Merged

Conversation

pauldub
Copy link
Contributor

@pauldub pauldub commented Jul 1, 2023

The file watcher used by the dev server to automatically reload on changes seems to have issues with large directories with Ubuntu (see #1714).

The System.FSNotify API does not allow us to exclude sub-trees from the paths watched by watchTree. Instead we can watch file changes in the root directory using watchDir and use watchTree on sub-directories excluding .direnv and .devenv which are known to be large directories and are not relevant with regard do reloading.

We also keep track of directories added and removed from the root directory and watch them accordingly.

IHP/IDE/FileWatcher.hs Outdated Show resolved Hide resolved
When a directory is added or removed from the root directory of the application, we start
or stop watching it accordingly.
@pauldub pauldub force-pushed the feat-devserver-fs-improvement branch from 7adac3d to e49d955 Compare July 6, 2023 05:44
@pauldub pauldub force-pushed the feat-devserver-fs-improvement branch from c6ce6c4 to 8829bd4 Compare July 6, 2023 05:48
When we stop watching a directory we do not need to test whether it is
watchable or not. It being in the WatchedDirectories state is sufficient
@mpscholten mpscholten marked this pull request as ready for review July 6, 2023 07:10
Copy link
Member

@mpscholten mpscholten left a comment

Choose a reason for hiding this comment

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

Thanks 👍 Looks good to me.

Just one tiny thing: Can we switch to 4 space indentation? (That's mostly the standard across the IHP code base, except some nix files)

@pauldub
Copy link
Contributor Author

pauldub commented Jul 6, 2023

Just one tiny thing: Can we switch to 4 space indentation? (That's mostly the standard across the IHP code base, except some nix files)

Sure thing, my editor setup might be messed up.

@mpscholten mpscholten merged commit 4f215f0 into digitallyinduced:master Jul 6, 2023
@mpscholten
Copy link
Member

Thanks again for the PR :) 👍

@pauldub
Copy link
Contributor Author

pauldub commented Jul 6, 2023

Welcome! It's a pleasure contributing to IHP.

@s0kil
Copy link
Collaborator

s0kil commented Jul 11, 2023

Changes here break auto reloading in my project, also using Ubuntu based distro, have to investigate.

@pauldub
Copy link
Contributor Author

pauldub commented Jul 12, 2023

Changes here break auto reloading in my project, also using Ubuntu based distro, have to investigate.

Was it working before this commit? It really shouldn't change anything except for the fact that we exclude a few select directories from the file watcher.

Do you have large directories within your project root?

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.

3 participants