fix: resolve event listener and timer cleanup leaks causing memory growth#832
fix: resolve event listener and timer cleanup leaks causing memory growth#832
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
WalkthroughThree files fix event listener cleanup issues and improve hook dependency management. SubMenuButton corrects mouseover listener cleanup, use-auto-disconnect replaces clearTimeout with clearInterval, and use-modal-close-event introduces useCallback memoization and fixes listener cleanup logic. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|



Summary
useModalCloseEvent: Cleanup calledaddEventListenerinstead ofremoveEventListener, accumulatingkeydownlisteners on every unmountSubMenuButton: Cleanup removedmouseoverinstead ofmousemove, leaving dangling listeners ondocumentacross all pagesuseAutoDisconnect: Cleanup calledclearTimeouton asetIntervalID, preventing the 10s background check internal from ever being clearedChanges
useModalCloseEventwindow.addEventListener("keydown", handleEsc)in cleanupwindow.removeEventListener("keydown", handleEsc)useCallbackwith proper depsuseEffectdeps:[]useEffectdeps:[handleEsc, onClickOutbound]SubMenuButtonremoveEventListener("mouseover", ...)removeEventListener("mousemove", ...)useAutoDisconnectclearTimeout(backgroundCheckIntervalRef.current)clearInterval(backgroundCheckIntervalRef.current)Performance Measurements
Tested by opening/closing a SelectBox dropdown 10 times and recording Chrome DevTools Performance for ~15 seconds.
Before (tested on beta.gnoswap.io)
After (tested on Vercel preview)
Results
Summary by CodeRabbit