Repository navigation
🐛 [RUM-19516] Collect pending resources in a page exit phase before finalizing events - #5230
Draft
BeltranBulbarellaDD wants to merge 1 commit into
Draft
BeltranBulbarellaDD wants to merge 1 commit into
BeltranBulbarellaDD wants to merge 1 commit into
Conversation
…inalizing events refs: RUM-19516 Resource events wait in an idle-callback task queue for up to 1s, and pending tasks were dropped when the page exited, so resources that finished right before the exit were never sent. Split page exit in two lifecycle phases, notified synchronously before the batch flush: COLLECT_PENDING_EVENTS, where resource collection flushes its task queue, then PREPARE_URGENT_FLUSH, where views and actions finalize their events and so count the collected resources. This doesn't depend on the order collections are started in. - TaskQueue.flush() runs pending tasks synchronously, each through callMonitored so a failing task doesn't prevent the batch from being sent. - Discard resources with a non-finite duration (ex: when `performance` is replaced by Playwright's fake clock). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bundles Sizes Evolution
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: c34f13e | Docs | View more details | Give us feedback! |
This branch has not been deployed
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.
Motivation
Alternative to #5227 for RUM-19516: resource events wait in an idle-callback task queue (up to 1s) and are dropped when the page exits, so resources that finish right before the user leaves are never sent.
#5227 drains the queue on
PREPARE_URGENT_FLUSHand relies on resource collection starting before view collection instartRum, so the final view update counts the drained resources. This PR makes that order explicit instead, with two page exit phases.Changes
COLLECT_PENDING_EVENTSlifecycle event, notified right beforePREPARE_URGENT_FLUSH(batch and event bridge paths):COLLECT_PENDING_EVENTS: collections emit what they are still processing. Resource collection flushes its task queue.PREPARE_URGENT_FLUSH: collections finalize their events (views, click actions…), which include what phase 1 collected.TaskQueue.flush(): runs pending tasks synchronously, each throughcallMonitoredso a failing task doesn't prevent the batch from being sent.performanceis replaced, e.g. Playwright'spage.clock.install()).Same behavior as #5227, without depending on the order collections are started in.
COLLECT_PENDING_EVENTSis also wheretakeRecords()or the replay mutation flush could go later.Test instructions
yarn test:unit:startRum.spec.tschecks that the view and click actionresource.countinclude the resources collected on unload. See #5227 for the e2e reproduction.Checklist
🤖 Generated with Claude Code