-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
Good catch! |
There was a problem hiding this 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); | ||
} | ||
}; |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip!
…interval (#15891) * fix memory leak by adding desctructor to clear credit check interval * simplify destructor
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