Add progress tracking for downloads and model states#2470
Closed
ComputelessComputer wants to merge 1 commit intomainfrom
Closed
Add progress tracking for downloads and model states#2470ComputelessComputer wants to merge 1 commit intomainfrom
ComputelessComputer wants to merge 1 commit intomainfrom
Conversation
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyprnote-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Comment on lines
+159
to
+169
| if (!globalShowBanner && !globalBannerTimer) { | ||
| globalBannerTimer = setTimeout(() => { | ||
| globalShowBanner = true; | ||
| setShowBanner(true); | ||
| globalBannerTimer = null; | ||
| }, BANNER_CHECK_DELAY_MS); | ||
| } else if (globalShowBanner) { | ||
| setShowBanner(true); | ||
| }, BANNER_CHECK_DELAY_MS); | ||
| } | ||
|
|
||
| return () => clearTimeout(timer); | ||
| return () => {}; |
Contributor
There was a problem hiding this comment.
Memory leak: The cleanup function no longer clears the timer when the component unmounts. If the component unmounts before BANNER_CHECK_DELAY_MS expires, the timer will continue to run and call setShowBanner(true) on an unmounted component, causing a React warning and potential memory leak.
Fix:
return () => {
if (globalBannerTimer) {
clearTimeout(globalBannerTimer);
globalBannerTimer = null;
}
};The global timer needs to be properly cleaned up to prevent the callback from executing after unmount.
Suggested change
| if (!globalShowBanner && !globalBannerTimer) { | |
| globalBannerTimer = setTimeout(() => { | |
| globalShowBanner = true; | |
| setShowBanner(true); | |
| globalBannerTimer = null; | |
| }, BANNER_CHECK_DELAY_MS); | |
| } else if (globalShowBanner) { | |
| setShowBanner(true); | |
| }, BANNER_CHECK_DELAY_MS); | |
| } | |
| return () => clearTimeout(timer); | |
| return () => {}; | |
| if (!globalShowBanner && !globalBannerTimer) { | |
| globalBannerTimer = setTimeout(() => { | |
| globalShowBanner = true; | |
| setShowBanner(true); | |
| globalBannerTimer = null; | |
| }, BANNER_CHECK_DELAY_MS); | |
| } else if (globalShowBanner) { | |
| setShowBanner(true); | |
| } | |
| return () => { | |
| if (globalBannerTimer) { | |
| clearTimeout(globalBannerTimer); | |
| globalBannerTimer = null; | |
| } | |
| }; |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
Collaborator
Author
|
dupe #2671 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
to show download progress in main app with inside a toast, after downloading ai models in onboarding
related: #2468
flow: download model in onboarding -> shows download progress toast in main window