Pattern: How to handle cross-iframe timing/race conditions?

Documentation for Sessions

🎨 Pattern: How to handle cross-iframe timing/race conditions?

Date: 2026-01-28
Time: 22:20:06 UTC
Session: editor2-73.16
Agent: angular
Confidence: 90%
Status: ✅ Documented


📋 Decision Context

Question:

How to handle cross-iframe timing/race conditions?

Task: Not specified


🎯 Decision Made

Chosen:

Retry pattern + fallback cleanup + ID-based element tracking

Options Considered:


💭 Reasoning

Cross-iframe communication via postMessage is asynchronous and can have timing issues. Key patterns: 1) Retry important messages (AI_APP_READY) multiple times at increasing intervals. 2) Always clean up orphaned elements by ID before creating new ones. 3) Add fallback cleanup that runs after a timeout to catch any missed cleanup. 4) Use guards to prevent double-processing (check isDragging state before handling dragEnd).


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation