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

app reloads when starting #2182

Open
illume opened this issue Jul 22, 2024 · 1 comment
Open

app reloads when starting #2182

illume opened this issue Jul 22, 2024 · 1 comment
Labels
app bug Something isn't working

Comments

@illume
Copy link
Collaborator

illume commented Jul 22, 2024

When starting the app, I see it load, and then reload about 2 seconds after. It's much quicker when not in developer mode, but it does still reload.

I tried this with current main, and also a previous release 0.24.1. I'm not sure how long it's been happening, and haven't bisected back further.

It's not such a problem because in release mode it's very quick and barely noticeable. In dev mode it's just slightly annoying (to me anyway).

@sniok
Copy link
Contributor

sniok commented Aug 1, 2024

I've looked a bit more into this. When starting the backend it will start watching for plugin changes. When it detects change it will send a X-Reload header to the frontend.

But it also happens just when starting backend for the first time. You can notice the following log in the backend output

 {"level":"info","source":"/home/dubenko/headlamp/backend/pkg/plugins/plugins.go","line":224,"time":"2024-08-01T12:23:23+02:00","message":"Sending reload plugins signal to frontend"}

I've traced it down to plugins.go file. It manually sends a fsevent for all files on the first run, I think this is the issue

func periodicallyWatchSubfolders(watcher *fsnotify.Watcher, path string, interval time.Duration) {
// ...
				// when a folder is added, send events for all the files in the folder
				entries, err := os.ReadDir(path)
				if err != nil {
					logger.Log(logger.LevelError, map[string]string{"path": path},
						err, "reading dir")

					return err
				}
				for _, entry := range entries {
					watcher.Events <- fsnotify.Event{Name: filepath.Join(path, entry.Name()), Op: fsnotify.Create}
				}
// ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app bug Something isn't working
Projects
Development

No branches or pull requests

2 participants