Skip to content

fix: add missing cleanup for event listeners and debounce timer#234

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
collinsezedike:fix/memory-leak-subscriptions-190
Apr 27, 2026
Merged

fix: add missing cleanup for event listeners and debounce timer#234
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
collinsezedike:fix/memory-leak-subscriptions-190

Conversation

@collinsezedike
Copy link
Copy Markdown
Contributor

Summary

  • usePWA: Named the appinstalled inline handler so it can be passed to removeEventListener in the effect cleanup
  • usePWA: Stored the updatefound handler in a ref (updateFoundHandlerRef) and added a useEffect that removes the listener from the ServiceWorkerRegistration on unmount
  • useSearch: Added a useEffect cleanup that clears the pending debounce timer on unmount, preventing a state update on an unmounted component

Test plan

  • Mount/unmount a component using usePWA — no appinstalled or updatefound listeners should remain attached
  • Type in a search field then unmount quickly — no state-update-on-unmounted-component warning in the console

Closes #190

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 27, 2026

@collinsezedike Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER RUKAYAT-CODER merged commit 56e1a8a into rinafcode:main Apr 27, 2026
3 of 6 checks passed
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.

Memory Leak in Subscriptions

2 participants