Skip to content

fix: filter CHILD_READY by iframe source to prevent handshake collision#12

Merged
ihatexcel merged 1 commit into
mainfrom
claude/setup-tsup-github-lib-KNfOE
May 11, 2026
Merged

fix: filter CHILD_READY by iframe source to prevent handshake collision#12
ihatexcel merged 1 commit into
mainfrom
claude/setup-tsup-github-lib-KNfOE

Conversation

@ihatexcel

Copy link
Copy Markdown
Owner

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

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
@ihatexcel ihatexcel merged commit eb3140e into main May 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants