Comments (6)
@a-h You are right about the dedup and debounce stuff. I didn't want to change the terminology of fsnotify and I marked the wrong place for the fix. I will correct it.
from templ.
Thanks @stefanohrmann for the thorough bug report, and your time spent investigating. I've marked this as NeedsInvestigation because I think it could be worth looking into the viability of a fix which doesn't involve removing any commands. Such as ignoring events where the file is empty.
from templ.
@joerdav You are right and I think it is totally possible to fix this issue in the current implementation if you apply the dedup stuff from fsnotify here:
templ/cmd/templ/generatecmd/watcher/watch.go
Lines 73 to 99 in 753ba39
And with my suggestion i didn't want to remove any subcommands. I wanted to add a dedicated one for watching. But it is ok if this doesn't fit in your structure.
Edit note: Changed the link to right place for the fix.
from templ.
Ah, not to dismiss your idea, just wanted to explore all options first, and I think minimal change to the outside API would be preferable.
from templ.
Great find, and nice write up.
From reading the fsnotify
dedup
function, it looks like it's more of a debounce than a deduplication, because it doesn't look at the message content (e.g. by having a windowing function or ring buffer of previous messages). It just waits for a timer to elapse before allowing the processing.
I think the logic to handle either a true deduplication (i.e. within a window of 100ms, if there is more than one operation of the same time, discard the earlier ones, and emit the latest), or debounce would go here:
templ/cmd/templ/generatecmd/watcher/watch.go
Lines 73 to 99 in 753ba39
from templ.
I've created a debounce implementation, for now I've put the window at 100ms I'm hoping that this will be enough.
from templ.
Related Issues (20)
- `templ generate` takes a long time for unformatted files HOT 6
- refactor: update `templ generate` to support pwd being a symlink HOT 3
- Templ formatting breaks imports at v0.2.747 HOT 7
- Composable templates do not render properly in tests HOT 1
- App freeze using air proxy HOT 1
- templ-vscode "Request textDocument/codeAction failed" HOT 2
- Streaming Not Working
- [Proposal] Improve embedding components HOT 2
- proposal: Go comments within HTML tags HOT 1
- Raw go errors if block ends with a comment
- LSP crashes after being started by kakoune-lsp HOT 4
- How to prevent cache HOT 1
- .templ file with only script elements leads to unused import HOT 1
- Anyway to instantiate a templ once per rendering context? HOT 4
- performance: templ parse takes a long time and uses high CPU when unclosed void elements are used HOT 8
- Little typo in streaming documentation
- bug: `templ generate --watch --proxy` triggers 2 browser reload events HOT 1
- bug: ambiguous child/string expression grammar HOT 4
- bug: go to definition causes error in Neovim v0.10.x HOT 11
- LSP - gopls command error HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from templ.