fix: filter CHILD_READY by iframe source to prevent handshake collision#12
Merged
Merged
Conversation
Multiple ArrowParentEmitter instances on the same page all listened to every window message event. The first CHILD_READY from any iframe (e.g. child-alpha) would be accepted by all emitters, causing qsEmitter and chartEmitter to transition to READY before their own child connected. Subsequent send() calls then timed out because the actual iframe had no receiver yet. Fix: add event.source === this.iframe.contentWindow guard at the top of _initMessageListener so each emitter only processes messages from its own iframe. Demo: lazy-init qsEmitter and chartEmitter (src=about:blank initially, real src set on first navigation) to avoid competing CDN/resource loads at page startup. Also suppress spurious "✅ Ready" log when transitioning back from SENDING → READY. Tests: update dispatchMessage helper to accept a source, add dispatchFromIframe helper, update all relevant calls, add explicit regression test for cross-iframe message rejection. https://claude.ai/code/session_014XkyCi4sXUHdDjMstV2Pbt
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.
Multiple ArrowParentEmitter instances on the same page all listened to every window message event. The first CHILD_READY from any iframe (e.g. child-alpha) would be accepted by all emitters, causing qsEmitter and chartEmitter to transition to READY before their own child connected. Subsequent send() calls then timed out because the actual iframe had no receiver yet.
Fix: add event.source === this.iframe.contentWindow guard at the top of _initMessageListener so each emitter only processes messages from its own iframe.
Demo: lazy-init qsEmitter and chartEmitter (src=about:blank initially, real src set on first navigation) to avoid competing CDN/resource loads at page startup. Also suppress spurious "✅ Ready" log when transitioning back from SENDING → READY.
Tests: update dispatchMessage helper to accept a source, add dispatchFromIframe helper, update all relevant calls, add explicit regression test for cross-iframe message rejection.
https://claude.ai/code/session_014XkyCi4sXUHdDjMstV2Pbt