Skip to content

Notification Provider Bug Fixes 20260415

Paulo Gomes da Cruz Junior edited this page Apr 16, 2026 · 1 revision

Notification Provider Bug Fixes 20260415

Summary

Follow-up bug fixes to the notification event system refactor. The changes address three specific issues: memory leaks from missing cleanup function returns in useEffect, incorrect CSS class application preventing slide-out animations from completing, and improper error object serialization in service worker registration error handling.

Related Issues

  • #764

Goals

  • Eliminate memory leaks caused by unregistered notification event dispatchers on component unmount
  • Restore correct slide-out animation behavior for notifications
  • Ensure notification queue removal does not interrupt in-progress animations
  • Provide meaningful error messages when service worker registration fails

Changes

Structural Changes

  • Fixed useEffect cleanup pattern: registerNotificationEventDispatcher now properly returns the unregister function
  • Added new useEffect hook to manage async queue removal: decouples animation completion from queue state updates

Performance Improvements

  • Eliminated memory leak from missing event dispatcher unregistration on NotificationProvider unmount
  • Improved garbage collection: proper cleanup of timer references prevents memory accumulation

API / Data Flow Changes

None.

UI / UX Adjustments

  • Fixed notification slide-out animation: now applies slide-out class immediately instead of slide-in
  • Added 300ms delay before removing notification from queue: ensures animation completes before component unmounts

Cleanup and Simplification

  • Removed inline queue removal from onClose handler: moved to separate useEffect for better separation of concerns

Bug Fixes

  • Memory leak in NotificationProvider: unregister function not being called on unmount
  • Animation cut-off bug: setting slide-in instead of slide-out prevented slide-out animation from triggering
  • Premature queue removal: notification removed immediately, interrupting the 300ms slide-out animation
  • Error serialization in registerServiceWorker: JSON.stringify(error) produced empty objects for native Error instances

Impact

  • Eliminates memory leaks from event dispatcher not being properly unregistered
  • Ensures notification animations complete smoothly before component removal
  • Improves user experience with consistent, uninterrupted notification slide-out behavior
  • Provides meaningful error messages to users when service worker registration fails

Follow-up Work

  • Verify notification queue removal timing works correctly across different browser speeds
  • Consider making the 300ms delay configurable if animation duration changes
  • Test error handling in service worker registration across different failure scenarios
  • Add integration tests to verify animation timing and queue removal behavior

Waste Plus Wiki

Home

Architecture

Codes

Decisions

Knowledge Base

Development

Changes

Clone this wiki locally