I can Fix This..Please assign me
Describe the bug
MessageContext registers token refresh listeners whenever a new socket instance is created, but the listeners are never removed during cleanup or component unmount.
After multiple login/logout cycles or repeated remounts, multiple listeners remain active. As a result, a single token refresh event can trigger multiple socket reconnects and duplicate event handling.
Affected file:
frontend/src/app/MessageContext.tsx
To Reproduce
- Start the frontend and backend servers
- Log in to the application
- Navigate between pages or trigger socket reconnects
- Log out and log in again multiple times
- Trigger a token refresh event (or wait for automatic token refresh)
- Observe multiple reconnect attempts or duplicated socket events
Expected behavior
Only one token refresh listener should exist for the active socket lifecycle.
A token refresh event should:
- trigger a single reconnect attempt
- Avoid duplicate socket event handling
- properly clean up listeners during unmount/logout
Actual behaviour
Listeners accumulate over time because cleanup does not unregister them.
This can lead to:
- duplicate reconnect attempts
- stale socket instances
- repeated message/event handling
- increased memory usage
Possible Fix
- Remove token refresh listeners during cleanup/unmount
- Ensure listener registration happens only once per socket lifecycle
- Add unsubscribe handling for
addTokenRefreshListener
Additional context
Relevant section:
frontend/src/app/MessageContext.tsx
Potential impact becomes more visible after:
- repeated authentication changes
- hot reloads during development
- prolonged app sessions
- reconnect-heavy network conditions
Suggested labels
- bug
- frontend
- websocket
- performance
I can Fix This..Please assign me
Describe the bug
MessageContextregisters token refresh listeners whenever a new socket instance is created, but the listeners are never removed during cleanup or component unmount.After multiple login/logout cycles or repeated remounts, multiple listeners remain active. As a result, a single token refresh event can trigger multiple socket reconnects and duplicate event handling.
Affected file:
frontend/src/app/MessageContext.tsxTo Reproduce
Expected behavior
Only one token refresh listener should exist for the active socket lifecycle.
A token refresh event should:
Actual behaviour
Listeners accumulate over time because cleanup does not unregister them.
This can lead to:
Possible Fix
addTokenRefreshListenerAdditional context
Relevant section:
frontend/src/app/MessageContext.tsxPotential impact becomes more visible after:
Suggested labels