Skip to content

Deduplicate concurrent rrweb uploads - #1347

Open
vladislav805 wants to merge 2 commits into
gemini-testing:masterfrom
vladislav805:fix/dedupe-rrweb-installation
Open

vladislav805 wants to merge 2 commits into
gemini-testing:masterfrom
vladislav805:fix/dedupe-rrweb-installation

Conversation

@vladislav805

Copy link
Copy Markdown

After navigation, concurrent DOM snapshot collectors can each detect missing rrweb and upload the entire library to the same browser session.

Share one in-flight upload per session while keeping event collection independent for each caller. Already-installed rrweb collections remain concurrent.

Invalidate pending collectors when cleanup starts. Discard late events to prevent mixing snapshots between retries, and preserve newer installation state when older operations finish.

Repeated navigation is handled with a bounded retry loop. Add debug logs for uploads, waits and discarded events.

{"pid":59141,"timeMs":15935.628006,"browserId":"searchapp-emulator","transport":"custom","requestId":"59141:8","command":"executeScript","method":"POST","endpointKind":"execute/sync","startedMs":14502.471859,"scriptHash":"51176f21e8c6b6f4032bf8170d086ab5fb23ca0cfd205087751d25174b0b2f8f","payloadBytes":4936,"scriptFamily":"rrweb","rrwebCodeProvided":false,"rrwebCodeBytes":0,"event":"result","matchedByBodyIdentity":true,"error":false,"isRrwebInstalled":false,"isRrwebSupported":null,"rrwebEventCount":0,"elapsedSinceCommandMs":1433.1541969999998,"pendingTotal":9,"pendingRrweb":8}
{"pid":59141,"timeMs":15936.674345,"browserId":"searchapp-emulator","transport":"custom","requestId":"59141:18","command":"executeScript","method":"POST","endpointKind":"execute/sync","startedMs":15936.622415,"scriptHash":"51176f21e8c6b6f4032bf8170d086ab5fb23ca0cfd205087751d25174b0b2f8f","payloadBytes":4936,"scriptFamily":"rrweb","rrwebCodeProvided":true,"rrwebCodeBytes":182637,"event":"command","pendingTotal":8,"pendingRrweb":7,"pendingRequestIds":["59141:9","59141:10","59141:11","59141:12","59141:14","59141:15","59141:16","59141:17"]}
...
{"pid":59141,"timeMs":15969.511889,"browserId":"searchapp-emulator","transport":"custom","requestId":"59141:19","command":"executeScript","method":"POST","endpointKind":"execute/sync","startedMs":15969.456635,"scriptHash":"51176f21e8c6b6f4032bf8170d086ab5fb23ca0cfd205087751d25174b0b2f8f","payloadBytes":4936,"scriptFamily":"rrweb","rrwebCodeProvided":true,"rrwebCodeBytes":182637,"event":"command","pendingTotal":8,"pendingRrweb":7,"pendingRequestIds":["59141:9","59141:11","59141:12","59141:14","59141:15","59141:16","59141:17","59141:18"]}
...
{"pid":59141,"timeMs":15974.884561,"browserId":"searchapp-emulator","transport":"custom","requestId":"59141:20","command":"executeScript","method":"POST","endpointKind":"execute/sync","startedMs":15974.832516,"scriptHash":"51176f21e8c6b6f4032bf8170d086ab5fb23ca0cfd205087751d25174b0b2f8f","payloadBytes":4936,"scriptFamily":"rrweb","rrwebCodeProvided":true,"rrwebCodeBytes":182637,"event":"command","pendingTotal":8,"pendingRrweb":7,"pendingRequestIds":["59141:9","59141:12","59141:14","59141:15","59141:16","59141:17","59141:18","59141:19"]}
...
{"pid":59141,"timeMs":15990.724561,"browserId":"searchapp-emulator","transport":"custom","requestId":"59141:21","command":"executeScript","method":"POST","endpointKind":"execute/sync","startedMs":15990.673399,"scriptHash":"51176f21e8c6b6f4032bf8170d086ab5fb23ca0cfd205087751d25174b0b2f8f","payloadBytes":4936,"scriptFamily":"rrweb","rrwebCodeProvided":true,"rrwebCodeBytes":182637,"event":"command","pendingTotal":8,"pendingRrweb":7,"pendingRequestIds":["59141:9","59141:12","59141:15","59141:16","59141:17","59141:18","59141:19","59141:20"]}
...
{"pid":59141,"timeMs":15996.223394,"browserId":"searchapp-emulator","transport":"custom","requestId":"59141:22","command":"executeScript","method":"POST","endpointKind":"execute/sync","startedMs":15996.150454,"scriptHash":"51176f21e8c6b6f4032bf8170d086ab5fb23ca0cfd205087751d25174b0b2f8f","payloadBytes":4936,"scriptFamily":"rrweb","rrwebCodeProvided":true,"rrwebCodeBytes":182637,"event":"command","pendingTotal":8,"pendingRrweb":7,"pendingRequestIds":["59141:9","59141:15","59141:16","59141:17","59141:18","59141:19","59141:20","59141:21"]}
...
{"pid":59141,"timeMs":16004.584468,"browserId":"searchapp-emulator","transport":"custom","requestId":"59141:23","command":"executeScript","method":"POST","endpointKind":"execute/sync","startedMs":16004.532853,"scriptHash":"51176f21e8c6b6f4032bf8170d086ab5fb23ca0cfd205087751d25174b0b2f8f","payloadBytes":4936,"scriptFamily":"rrweb","rrwebCodeProvided":true,"rrwebCodeBytes":182637,"event":"command","pendingTotal":8,"pendingRrweb":7,"pendingRequestIds":["59141:15","59141:16","59141:17","59141:18","59141:19","59141:20","59141:21","59141:22"]}
...
{"pid":59141,"timeMs":16011.505688,"browserId":"searchapp-emulator","transport":"custom","requestId":"59141:24","command":"executeScript","method":"POST","endpointKind":"execute/sync","startedMs":16011.459448,"scriptHash":"51176f21e8c6b6f4032bf8170d086ab5fb23ca0cfd205087751d25174b0b2f8f","payloadBytes":4936,"scriptFamily":"rrweb","rrwebCodeProvided":true,"rrwebCodeBytes":182637,"event":"command","pendingTotal":8,"pendingRrweb":7,"pendingRequestIds":["59141:16","59141:17","59141:18","59141:19","59141:20","59141:21","59141:22","59141:23"]}
...
{"pid":59141,"timeMs":16027.025136,"browserId":"searchapp-emulator","transport":"custom","requestId":"59141:27","command":"executeScript","method":"POST","endpointKind":"execute/sync","startedMs":16026.976661,"scriptHash":"51176f21e8c6b6f4032bf8170d086ab5fb23ca0cfd205087751d25174b0b2f8f","payloadBytes":4936,"scriptFamily":"rrweb","rrwebCodeProvided":true,"rrwebCodeBytes":182637,"event":"command","pendingTotal":9,"pendingRrweb":8,"pendingRequestIds":["59141:18","59141:19","59141:20","59141:21","59141:22","59141:23","59141:24","59141:25","59141:26"]}
...
{"pid":59141,"timeMs":16301.23965,"browserId":"searchapp-emulator","transport":"custom","requestId":"59141:19","command":"executeScript","method":"POST","endpointKind":"execute/sync","startedMs":15969.456635,"scriptHash":"51176f21e8c6b6f4032bf8170d086ab5fb23ca0cfd205087751d25174b0b2f8f","payloadBytes":4936,"scriptFamily":"rrweb","rrwebCodeProvided":true,"rrwebCodeBytes":182637,"event":"result","matchedByBodyIdentity":true,"error":false,"isRrwebInstalled":true,"isRrwebSupported":null,"rrwebEventCount":53,"elapsedSinceCommandMs":331.7771679999987,"pendingTotal":10,"pendingRrweb":9}

@sipayRT sipayRT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One remaining deduplication edge case involving delayed probe responses:

Comment thread src/browser/history/rrweb.ts
@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/gemini-testing/testplane@1347

commit: 2580464

@vladislav805
vladislav805 force-pushed the fix/dedupe-rrweb-installation branch from 4b68b12 to 2580464 Compare October 21, 2026 09:51
@vladislav805

Copy link
Copy Markdown
Author

@sipayRT, fixed in 4b68b12. We now track completed uploads as well as in-flight ones. If a missing response predates a completed upload, the caller probes again without sending the library. If that fresh probe still reports missing, a new upload is allowed.

Added regression tests for delayed responses, navigation, unsupported installation, and cleanup.

@vladislav805
vladislav805 requested a review from sipayRT October 26, 2026 10:45
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