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

Fix leaving .turbo-cookie around #2180

Merged
merged 5 commits into from
Oct 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/internal/filewatcher/backend_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,18 @@ func (f *fseventsBackend) AddRoot(someRoot turbopath.AbsoluteSystemPath, exclude
}

func waitForCookie(root turbopath.AbsoluteSystemPath, events <-chan []fsevents.Event, timeout time.Duration) error {
// This cookie needs to be in a location that we're watching, and at this point we can't guarantee
// what the root is, or if something like "node_modules/.cache/turbo" would make sense. As a compromise, ensure
// that we clean it up even in the event of a failure.
cookiePath := root.UntypedJoin(".turbo-cookie")
if err := cookiePath.WriteFile([]byte("cookie"), 0755); err != nil {
return err
}
expected := cookiePath.ToString()[1:] // trim leading slash
if err := waitForEvent(events, expected, fsevents.ItemCreated, timeout); err != nil {
// Attempt to not leave the cookie file lying around.
// Ignore the error, since there's not much we can do with it.
_ = cookiePath.Remove()
return err
}
if err := cookiePath.Remove(); err != nil {
Expand Down