fix(screencast): await pending auto-save in page.close()#1
Open
Git-Raini wants to merge 1 commit into
Open
Conversation
Addresses review feedback: microsoft#41744 (comment) The auto-save triggered from the once(Events.Page.Close) listener was fire-and-forget, so page.close() could resolve before the video was actually written to disk - nothing guaranteed ordering, and a failed save was silently swallowed with no signal at all. Screencast now tracks the in-flight save as _pendingAutoSave, and Page.close() awaits it in a finally block. This is safe because the server dispatches the 'close' event (which triggers the auto-save) before it sends the response to the close() call itself, so the promise is always already assigned by the time page.close() reaches its finally block. Verified with 195 runs (13 tests x 15 repeats) of screencast.spec.ts, all passing, plus the full page-close.spec.ts suite (47 tests) with no regressions.
This was referenced Jul 12, 2026
25133ae to
a5c1fb4
Compare
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.
Follow-up to review comment on microsoft#41744 (comment)
The auto-save triggered from the
once(Events.Page.Close, ...)listener was fire-and-forget -artifact.saveAs(savePath).catch(() => {})with nothing awaiting it. That meantpage.close()could resolve before the video was actually on disk, and a failed save produced no signal at all.Screencastnow tracks the in-flight save as_pendingAutoSave, andPage.close()awaits it in afinallyblock. This is safe: I tracedPageDispatcherand confirmed the server dispatches the'close'event (which triggers the auto-save) before it sends the response to theclose()call itself - so_pendingAutoSaveis always already assigned by the timepage.close()reaches itsfinallyblock, regardless of which close path was taken (_ownedContext.close(),runBeforeUnload, or direct_channel.close()).Diff:
Test results - screencast.spec.ts, 195 runs (13 tests × 15 repeats), all passing
Test results - full page-close.spec.ts suite (18 tests), no regressions
Also confirmed
tsc --noEmitandeslintclean on both changed files.