Repository navigation
Add event listener memory leak detection tests - #175
Merged
Merged
Conversation
Implemented 12 tests across 4 categories to verify proper event listener cleanup: Component Lifecycle (4 tests): - NodeAutocomplete removes keydown listener on unmount - SlashCommandDropdown removes keydown listener on unmount - No listener accumulation over multiple mount/unmount cycles - Cleanup resilient to errors during unmount Rapid Operations (3 tests): - 100 rapid mount/unmount cycles without leaking - Listener count returns to baseline after rapid operations - Acceptable memory usage during mixed component operations EventBus Subscriptions (3 tests): - Unsubscribe actually removes handlers - reset() clears all handlers - Wildcard subscriptions cleaned up properly Verification Tools (2 tests): - Programmatic leak detection capability - Accurate handler count measurement All tests verify that document event listeners and EventBus subscriptions are properly cleaned up to prevent memory leaks during normal and edge-case scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Implemented all critical, important, and optional improvements from PR review: **Critical Fixes:** - Add handler reference verification (Finding #3) - Tests #1 and #2 now verify exact handler reference equality - Ensures removeEventListener receives same function reference as addEventListener - Prevents common memory leak bug of creating new functions **Important Improvements:** - Rename test #4 to match actual behavior (Finding #1) - Changed "error during unmount" → "normal unmount lifecycle" - Added explanatory comment about Svelte's onDestroy guarantees - Add explicit cleanup to test #7 (Finding #5) - Intentional leak test now properly unmounts component - Verifies cleanup worked by checking balance returns to initial state - Ensures test isolation and prevents cross-test contamination **Code Quality Enhancements:** - Extract helper functions for common spy patterns (Suggestion #4) - getKeydownListenerCounts(): Centralizes listener counting logic - getKeydownListenerHandlers(): Extracts handler reference tracking - measureListenerDelta(): Standard baseline measurement pattern - Standardize baseline measurement patterns (Finding #2) - All rapid operation tests now use consistent slice() pattern - Improved readability and maintainability - Consistent terminology (added/removed/balance) **Results:** - All 12 tests still pass ✅ - Zero lint/format warnings ✅ - Improved test reliability and maintainability - Better documentation of test intent 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 4, 2026
* Add comprehensive event listener memory leak detection tests Implemented 12 tests across 4 categories to verify proper event listener cleanup: Component Lifecycle (4 tests): - NodeAutocomplete removes keydown listener on unmount - SlashCommandDropdown removes keydown listener on unmount - No listener accumulation over multiple mount/unmount cycles - Cleanup resilient to errors during unmount Rapid Operations (3 tests): - 100 rapid mount/unmount cycles without leaking - Listener count returns to baseline after rapid operations - Acceptable memory usage during mixed component operations EventBus Subscriptions (3 tests): - Unsubscribe actually removes handlers - reset() clears all handlers - Wildcard subscriptions cleaned up properly Verification Tools (2 tests): - Programmatic leak detection capability - Accurate handler count measurement All tests verify that document event listeners and EventBus subscriptions are properly cleaned up to prevent memory leaks during normal and edge-case scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address all code review findings for event listener tests Implemented all critical, important, and optional improvements from PR review: **Critical Fixes:** - Add handler reference verification (Finding #3) - Tests #1 and #2 now verify exact handler reference equality - Ensures removeEventListener receives same function reference as addEventListener - Prevents common memory leak bug of creating new functions **Important Improvements:** - Rename test #4 to match actual behavior (Finding #1) - Changed "error during unmount" → "normal unmount lifecycle" - Added explanatory comment about Svelte's onDestroy guarantees - Add explicit cleanup to test #7 (Finding #5) - Intentional leak test now properly unmounts component - Verifies cleanup worked by checking balance returns to initial state - Ensures test isolation and prevents cross-test contamination **Code Quality Enhancements:** - Extract helper functions for common spy patterns (Suggestion #4) - getKeydownListenerCounts(): Centralizes listener counting logic - getKeydownListenerHandlers(): Extracts handler reference tracking - measureListenerDelta(): Standard baseline measurement pattern - Standardize baseline measurement patterns (Finding #2) - All rapid operation tests now use consistent slice() pattern - Improved readability and maintainability - Consistent terminology (added/removed/balance) **Results:** - All 12 tests still pass ✅ - Zero lint/format warnings ✅ - Improved test reliability and maintainability - Better documentation of test intent 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 5, 2026
* Add comprehensive event listener memory leak detection tests Implemented 12 tests across 4 categories to verify proper event listener cleanup: Component Lifecycle (4 tests): - NodeAutocomplete removes keydown listener on unmount - SlashCommandDropdown removes keydown listener on unmount - No listener accumulation over multiple mount/unmount cycles - Cleanup resilient to errors during unmount Rapid Operations (3 tests): - 100 rapid mount/unmount cycles without leaking - Listener count returns to baseline after rapid operations - Acceptable memory usage during mixed component operations EventBus Subscriptions (3 tests): - Unsubscribe actually removes handlers - reset() clears all handlers - Wildcard subscriptions cleaned up properly Verification Tools (2 tests): - Programmatic leak detection capability - Accurate handler count measurement All tests verify that document event listeners and EventBus subscriptions are properly cleaned up to prevent memory leaks during normal and edge-case scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address all code review findings for event listener tests Implemented all critical, important, and optional improvements from PR review: **Critical Fixes:** - Add handler reference verification (Finding #3) - Tests #1 and #2 now verify exact handler reference equality - Ensures removeEventListener receives same function reference as addEventListener - Prevents common memory leak bug of creating new functions **Important Improvements:** - Rename test #4 to match actual behavior (Finding #1) - Changed "error during unmount" → "normal unmount lifecycle" - Added explanatory comment about Svelte's onDestroy guarantees - Add explicit cleanup to test #7 (Finding #5) - Intentional leak test now properly unmounts component - Verifies cleanup worked by checking balance returns to initial state - Ensures test isolation and prevents cross-test contamination **Code Quality Enhancements:** - Extract helper functions for common spy patterns (Suggestion #4) - getKeydownListenerCounts(): Centralizes listener counting logic - getKeydownListenerHandlers(): Extracts handler reference tracking - measureListenerDelta(): Standard baseline measurement pattern - Standardize baseline measurement patterns (Finding #2) - All rapid operation tests now use consistent slice() pattern - Improved readability and maintainability - Consistent terminology (added/removed/balance) **Results:** - All 12 tests still pass ✅ - Zero lint/format warnings ✅ - Improved test reliability and maintainability - Better documentation of test intent 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 26, 2026
* Add comprehensive event listener memory leak detection tests Implemented 12 tests across 4 categories to verify proper event listener cleanup: Component Lifecycle (4 tests): - NodeAutocomplete removes keydown listener on unmount - SlashCommandDropdown removes keydown listener on unmount - No listener accumulation over multiple mount/unmount cycles - Cleanup resilient to errors during unmount Rapid Operations (3 tests): - 100 rapid mount/unmount cycles without leaking - Listener count returns to baseline after rapid operations - Acceptable memory usage during mixed component operations EventBus Subscriptions (3 tests): - Unsubscribe actually removes handlers - reset() clears all handlers - Wildcard subscriptions cleaned up properly Verification Tools (2 tests): - Programmatic leak detection capability - Accurate handler count measurement All tests verify that document event listeners and EventBus subscriptions are properly cleaned up to prevent memory leaks during normal and edge-case scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address all code review findings for event listener tests Implemented all critical, important, and optional improvements from PR review: **Critical Fixes:** - Add handler reference verification (Finding #3) - Tests #1 and #2 now verify exact handler reference equality - Ensures removeEventListener receives same function reference as addEventListener - Prevents common memory leak bug of creating new functions **Important Improvements:** - Rename test #4 to match actual behavior (Finding #1) - Changed "error during unmount" → "normal unmount lifecycle" - Added explanatory comment about Svelte's onDestroy guarantees - Add explicit cleanup to test #7 (Finding #5) - Intentional leak test now properly unmounts component - Verifies cleanup worked by checking balance returns to initial state - Ensures test isolation and prevents cross-test contamination **Code Quality Enhancements:** - Extract helper functions for common spy patterns (Suggestion #4) - getKeydownListenerCounts(): Centralizes listener counting logic - getKeydownListenerHandlers(): Extracts handler reference tracking - measureListenerDelta(): Standard baseline measurement pattern - Standardize baseline measurement patterns (Finding #2) - All rapid operation tests now use consistent slice() pattern - Improved readability and maintainability - Consistent terminology (added/removed/balance) **Results:** - All 12 tests still pass ✅ - Zero lint/format warnings ✅ - Improved test reliability and maintainability - Better documentation of test intent 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
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.
Closes #162