vugu / vgrun

Command line Vugu runner utility
MIT License
4 stars 3 forks source link

vugu is not compiled: **change detected too quickly, debouncing** #4

Open simulot opened 3 years ago

simulot commented 3 years ago

As learning project, I try to make a TODO application with vugu. My intention is to break components into packages. I run vgrun -v main.go to watch changes and the generate.go contains:

package main

//go:generate vugugen -s -r

My component isn't generated when I save the front/pages/Page1.vugu file The verbose option gives:

2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/.vscode
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/back
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/back/http
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/back/http/rest
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/back/repository
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/back/repository/memory
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/back/service
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/bin
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/front
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/front/list
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/front/pages
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/front/pages/page1
2021/02/17 18:43:19 RWatcher adding: /home/jfcassan/go/src/github.com/simulot/vugu-todo/todo

...

2021/02/17 18:43:56 DEBUG: watcher: "/home/jfcassan/go/src/github.com/simulot/vugu-todo/front/pages/page1/page1.vugu" WRITE
2021/02/17 18:43:56 watcher: "/home/jfcassan/go/src/github.com/simulot/vugu-todo/front/pages/page1/page1.vugu" WRITE, rebuilding and restarting...
2021/02/17 18:43:56 Running generateAndBuild
2021/02/17 18:43:56 About to execute go: [go generate]
2021/02/17 18:43:56 About to execute go: [go build -o /home/jfcassan/go/src/github.com/simulot/vugu-todo/bin/main main.go] (dir=)
2021/02/17 18:43:56 Exiting generateAndBuild (err=<nil>)
2021/02/17 18:43:56 about to perform gracefulStop on pid=64773
2021/02/17 18:43:56 gracefulStop running on pid=64773
2021/02/17 18:43:56 gracefulStop Signal(os.Interrupt) ok, waiting for error from channel
2021/02/17 18:43:56 Process exited with error: signal: interrupt
2021/02/17 18:43:56 DEBUG: watcher: "/home/jfcassan/go/src/github.com/simulot/vugu-todo/front/pages/page1/page1.vugu" WRITE
2021/02/17 18:43:56 RWatcher intercept stat error on "/home/jfcassan/go/src/github.com/simulot/vugu-todo/root_vgen.go": stat /home/jfcassan/go/src/github.com/simulot/vugu-todo/root_vgen.go: no such file or directory
2021/02/17 18:43:56 watcher: "/home/jfcassan/go/src/github.com/simulot/vugu-todo/front/pages/page1/page1.vugu" WRITE, change detected too quickly, debouncing
2021/02/17 18:43:56 DEBUG: watcher: "/home/jfcassan/go/src/github.com/simulot/vugu-todo/root_vgen.go" CREATE
2021/02/17 18:43:56 DEBUG: watcher: "/home/jfcassan/go/src/github.com/simulot/vugu-todo/0_components_vgen.go" REMOVE
2021/02/17 18:43:56 DEBUG: watcher: "/home/jfcassan/go/src/github.com/simulot/vugu-todo/0_components_vgen.go" CREATE
2021/02/17 18:43:56 DEBUG: watcher: "/home/jfcassan/go/src/github.com/simulot/vugu-todo/0_components_vgen.go" WRITE
2021/02/17 18:43:56 RWatcher intercept stat error on "/home/jfcassan/go/src/github.com/simulot/vugu-todo/root_vgen.go": stat /home/jfcassan/go/src/github.com/simulot/vugu-todo/root_vgen.go: no such file or directory

Touching the file doesn't help to

Therefore, runing vugugen from shell vugugen -s -r front/pages/page1 generate the go component. I need to refresh the application path.

Editing the root.vugu file works as expected.

bradleypeabody commented 3 years ago

Interesting. I'm surprised I didn't run into this issue earlier. Definitely looks like debouncing is needed.

Actually - it looks like I did run into this before: https://github.com/vugu/vgrun/blob/master/vgrun-main.go#L202 but it didn't cause the same problems.

Probably this line https://github.com/vugu/vgrun/blob/master/vgrun-main.go#L229 can be changed to some sort of call that will wait, e.g. 100ms and then push to the channel, and if another one comes in within that 100ms it should cancel the first and start the wait over. I'll leave it open to be addressed when I have time, or otherwise I'd be happy to review a PR to fix this. The debounce timeout should have a sensible default and be configurable with a command line flag.

simulot commented 3 years ago

I forgot to mention that I'm running under linux.

bradleypeabody commented 3 years ago

Thanks @simulot . If you're able to help with a fix for this, that would be amazing. Otherwise I'll leave this open and get to it when I can.

bobhy commented 1 year ago

Potential fix in #9?