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 small memory leak by adding destructor to clear credit check interval #15891

Merged
merged 3 commits into from
Aug 23, 2022

Conversation

lmossman
Copy link
Contributor

@lmossman lmossman commented Aug 23, 2022

What

Fixes a small memory leak we discovered in which the interval to check for credit increase after a credit purchase was not being cleared, causing the browser to continue to re-request the workspace every 3 seconds even if the user navigated away to another page.

How

Adds a destructor return method to the useEffectOnce() call in RemainingCredits to clear the interval upon component unmount.

Tested locally that this correctly fixes the leak - after this change, the repeated getWorkspace requests are not made after navigating to another page.

🚨 User Impact 🚨

No visible impact - just fewer unnecessary network calls

@github-actions github-actions bot added area/platform issues related to the platform area/frontend Related to the Airbyte webapp labels Aug 23, 2022
@lmossman lmossman marked this pull request as ready for review August 23, 2022 18:12
@lmossman lmossman requested a review from a team as a code owner August 23, 2022 18:12
@lmossman lmossman requested a review from timroes August 23, 2022 18:12
@edmundito
Copy link
Contributor

Good catch!

Copy link
Contributor

@krishnaglick krishnaglick left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

if (retryIntervalId.current) {
clearInterval(retryIntervalId.current);
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Fun fact: You don't need to check if it's even set, clearInterval is happy with any input!
return () => clearInterval(retryIntervalId.current);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip!

@lmossman lmossman merged commit 37a7dda into master Aug 23, 2022
@lmossman lmossman deleted the lmossman/fix-memory-leak branch August 23, 2022 22:13
rodireich pushed a commit that referenced this pull request Aug 25, 2022
…interval (#15891)

* fix memory leak by adding desctructor to clear credit check interval

* simplify destructor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants