# why
- network events can begin in iframes before stagehand has a chance to
install tracking. this means events get missed.
# what changed
- this PR queues tracker installation & `Network.enable` before the
iframe is resumed
- events that arrive before we know what page owns them (we call them
pending network captures) are buffered & then transferred to their
owning page in order
- if attachment fails or the iframe closes, we dispose all pending
captures
# test plan
- added unit tests for buffering, ownership transfer, ordering, &
cleanup
- added a real browser regression tests that cover immediate & later
requests in same-process and cross-process iframes
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes network tracking missing requests made immediately by newly
attached iframes.
Previously, Stagehand only started capturing network events after it
identified which page owned the iframe, so requests fired right after
attachment were lost. Now, capture is installed before the iframe
resumes, and events that arrive before ownership is known are buffered
and transferred to the owning page's network manager in arrival order.
- Events retain their original arrival timestamps through the transfer.
- Buffered events are discarded when attachment fails, the iframe
detaches or closes, or the frame tree query fails.
<sup>Written for commit 49e510999cead75daedb0742fdcdb4316e605942.
Summary will update on new commits.</sup>
<a
href="https://cubic.dev/pr/browserbase/stagehand/pull/3454?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/browserbase/stagehand/3454?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3454&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->