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

infinite rebuild loop using compute serve --watch #1332

Open
Svampen opened this issue Oct 30, 2024 · 1 comment
Open

infinite rebuild loop using compute serve --watch #1332

Svampen opened this issue Oct 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Svampen
Copy link

Svampen commented Oct 30, 2024

Version

fastly version (base) (story/CORE-734*) 14:01:01
fastly fastly version (base) (story/CORE-734*) 14:01:01
Fastly CLI version v10.15.0 (0a1665b)
Built with go version go1.22.7 linux/amd64 (2024-10-30)
Viceroy version: viceroy 0.12.1

What happened

Happens:

While running fastly compute serve --watch we ended up with an infinite loop of rebuilding, it seemed that something on the specific Mac, that was used, was doing a chmod operation as soon as fastly compute serve was issued creating an endless loop.
I debugged the fastly cli code and saw that it was always the fsnotify operation CHMOD.
Digging deeper into the code and into fsnotify it's stated in their documentation that taking action on Chmod isn't recommended.
See their code base: https://github.com/fsnotify/fsnotify/blob/2d133b81be1e26628491698a699ef9ce9fb71ed9/fsnotify.go#L135

Our theory is that company "must have" software (anti-virus) is getting triggered by the fastly compute serve operation
and that starts this loop.

Expecting:
Rebuild shouldn't occur if I haven't actually changed the files (write, create, remove, rename)

Temporary solution:
I patched the code by adding a if statement to only allow the event handler if the event had either Create, Remove, Rename, Write, which would exclude if it was only a Chmod operation.
I'm not sure if that's a good solution in the long run, maybe an cli option to control the behaviour of watch would be better

@Svampen Svampen added the bug Something isn't working label Oct 30, 2024
@kpfleming
Copy link
Contributor

Thanks for the excellent report! I agree with your findings and conclusion; the permission bits (mode) of the file are not relevant for triggering a rebuild, and it makes sense to only pay attention to the other modifications. Based on the comment in that link there are some non-mode changes which can also send a CHMOD event, but I don't see them as being a big concern (one is removal of a hard-link, and the other is truncation of a file).

If you want to submit a PR with your suggested changes to this logic, it would be very welcome.

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

No branches or pull requests

2 participants