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: debounce generate watch events #555

Merged
merged 5 commits into from
Feb 26, 2024
Merged

Conversation

joerdav
Copy link
Collaborator

@joerdav joerdav commented Feb 24, 2024

Fixes: #525

Copy link

@zolrath zolrath left a comment

Choose a reason for hiding this comment

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

A couple concrete things in the test suite along with a nit!

cmd/templ/generatecmd/watcher/watch_test.go Outdated Show resolved Hide resolved
cmd/templ/generatecmd/watcher/watch_test.go Outdated Show resolved Hide resolved
cmd/templ/generatecmd/watcher/watch_test.go Outdated Show resolved Hide resolved
cmd/templ/generatecmd/watcher/watch.go Show resolved Hide resolved
@stefanohrmann
Copy link

I looked through your changes and I think you are debouncing every fsnotify event regardless of the Op type, that means a REMOVE with a CREATE shortly after will emit as a REMOVE event. The example for debouncing/deduping of fsnotify has a guard for only applying the debouncing/deduping to CREATE/WRITE events:

https://github.com/fsnotify/fsnotify/blob/c94b93b0602779989a9af8c023505e99055c8fe5/cmd/fsnotify/dedup.go#L80-L82

@joerdav
Copy link
Collaborator Author

joerdav commented Feb 25, 2024

@stefanohrmann Interesting, seems the example you provided REMOVE would be skipped entirely. I wonder if we dedupe by only events with the same event?

@stefanohrmann
Copy link

@stefanohrmann Interesting, seems the example you provided REMOVE would be skipped entirely. I wonder if we dedupe by only events with the same event?

Yes the example is really simple and I think a REMOVE event should clear the timer and prevent the emitting of any previous CREATE/WRITE event(s). Your current implementation does only check for a certain filename/op combination and not that another event for the same filename was already scheduled.

Copy link
Owner

@a-h a-h left a comment

Choose a reason for hiding this comment

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

LGTM!

cmd/templ/generatecmd/watcher/watch.go Outdated Show resolved Hide resolved
cmd/templ/generatecmd/watcher/watch.go Show resolved Hide resolved
Co-authored-by: Adrian Hesketh <a-h@users.noreply.github.com>
@joerdav joerdav merged commit 9c6a3a0 into a-h:main Feb 26, 2024
4 checks passed
@joerdav joerdav deleted the debounce-fsnotify branch February 26, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants