I've been getting a weird bug in the past days, which I think is related to this.
- I have the main page that renders an iframe.
- The
iframerenders and sets up a listener on the main page. - At some point the
iframegoes away (its url changes) - The
iframedoes not have the opportunity to unsubscribe the listener - Host page receives event and tries to call the "dead" listener
- Probably garbage collected, because the process inside the iframe that created the function no longer exists
- Browser freezes and no error is being logged.
Could this be related to my bug?
Or calling a "dead" listener is just the same as trying to call an undefined value?
UPDATE
Yeah, it looks like this is the source of my problem. I added a code for my pubsub to log how many listeners it's trying to dispatch the event to.
And I'm getting way more listeners than I was supposed to have (I was expecting only two. One for the parent and one for the iframe). It publishes just fine for the 1st one (from the parent page), but the code kind of freezes on the second (which is probably from a dead iframe). I even wrapped it in a try{} catch{} but it does not throw any thing. It just freezes!