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 fs.watch leak with a timestamp to prevent repetitive buildFromConfig #7238

Merged
merged 3 commits into from
Jul 25, 2024

Conversation

mikeseese
Copy link
Contributor

@mikeseese mikeseese commented Jul 24, 2024

This PR fixes #6315 by preventing Tray::watchForChanges from calling in a cyclic behavior in the first place. The prior logic was was designed to prevent Tray::buildFromConfig from being called too frequently. The new logic calls Tray::buildFromConfig on each file change but the function will only continue if a second has passed since it was successfully called last time. With this, Tray::watchForChanges is only called once.

CC @mook-as

Signed-off-by: Mike Seese <seesemichaelj@gmail.com>
Copy link
Contributor

@mook-as mook-as left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I have some requests, but that doesn't mean the PR being completely rejected — I'm happy to be convinced otherwise.

If I understand your analysis in #6315 correctly, the watcher instances are in fact sticking around after the abort controller has triggered?

We may need to manually call close() on the watchers instead of relying on the abort signal?

pkg/rancher-desktop/main/tray.ts Outdated Show resolved Hide resolved
pkg/rancher-desktop/main/tray.ts Outdated Show resolved Hide resolved
Signed-off-by: Mike Seese <seesemichaelj@gmail.com>
@mikeseese mikeseese requested a review from mook-as July 24, 2024 18:03
Copy link
Contributor

@mook-as mook-as left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks pretty close now.

The only actually relevant changes are to change the comment style in one spot (super trivial), plus clearing runBuildFromConfigTimer in hide() (actual logic bug).

pkg/rancher-desktop/main/tray.ts Show resolved Hide resolved
pkg/rancher-desktop/main/tray.ts Outdated Show resolved Hide resolved
pkg/rancher-desktop/main/tray.ts Outdated Show resolved Hide resolved
pkg/rancher-desktop/main/tray.ts Show resolved Hide resolved
pkg/rancher-desktop/main/tray.ts Show resolved Hide resolved
Signed-off-by: Mike Seese <seesemichaelj@gmail.com>
@mikeseese mikeseese requested a review from mook-as July 24, 2024 19:31
Copy link
Contributor

@mook-as mook-as left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is being weird, but that's in yarn install and this doesn't have anything to do with that.

@mook-as mook-as merged commit e2706a5 into rancher-sandbox:main Jul 25, 2024
17 checks passed
@mikeseese mikeseese deleted the fix/fs-watch-memory-leak branch October 29, 2024 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Freeze after a few hours
3 participants