You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
## Description
The `CheckSessionService` is accumulating multiple event listeners for the 'message' event, causing the `messageHandler` to be executed multiple times for each event. This issue appears to have been introduced in PR #1735.
- Each time `bindMessageEventToIframe()` is called, a new event listener is added to `defaultView` without removing the previous one.
- This results in multiple executions of the `messageHandler` for a single 'message' event.
- The problem worsens over time as more listeners accumulate.
Steps to reproduce the behavior
1. Initialize the `CheckSessionService`.
2. Call `bindMessageEventToIframe()` multiple times (this may happen implicitly through other service methods).
3. Observe that 'message' events trigger multiple executions of the `messageHandler`.
A clear and concise description of what you expected to happen.
- Only one event listener should be active at any given time.
- When `bindMessageEventToIframe()` is called, it should remove any existing listener before adding a new one.
Additional context
Possible Solution
Modify the bindMessageEventToIframe() method to remove the existing listener before adding a new one:
privatebindMessageEventToIframe(configuration: OpenIdConfiguration): void{const defaultView =this.document.defaultView;// Remove existing listener if there is oneif(this.iframeMessageEventListener&&defaultView){defaultView.removeEventListener('message',this.iframeMessageEventListener,false);}// Create and assign the new listenerthis.iframeMessageEventListener=this.messageHandler.bind(this,configuration);if(defaultView){defaultView.addEventListener('message',this.iframeMessageEventListener,false);}}
The text was updated successfully, but these errors were encountered:
Version
18.0.1
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Steps to reproduce the behavior
A clear and concise description of what you expected to happen.
Additional context
Possible Solution
Modify the
bindMessageEventToIframe()
method to remove the existing listener before adding a new one:The text was updated successfully, but these errors were encountered: