Skip to content

Fix flaky PageGoBackTests.ShouldWork by awaiting navigation response#3133

Merged
kblok merged 1 commit intomasterfrom
fix/flaky-goback-navigation-response
Feb 14, 2026
Merged

Fix flaky PageGoBackTests.ShouldWork by awaiting navigation response#3133
kblok merged 1 commit intomasterfrom
fix/flaky-goback-navigation-response

Conversation

@kblok
Copy link
Member

@kblok kblok commented Feb 14, 2026

LifecycleWatcher.NavigationResponse was a synchronous property that read _navigationRequest?.Response immediately when the navigation lifecycle completed. This caused a race condition where the HTTP response hadn't been attached to the request object yet, returning null and causing NullReferenceException in tests.

Aligned with upstream Puppeteer by making NavigationResponse async, adding Response/RequestFailed event listeners to properly wait for the HTTP response to arrive before returning it.

@kblok kblok force-pushed the fix/flaky-goback-navigation-response branch from ea24d47 to 0c055c0 Compare February 14, 2026 17:24
Port upstream's async navigationResponse() pattern to PuppeteerSharp.
The LifecycleWatcher now tracks when the navigation response arrives via
a TaskCompletionSource that's resolved on Response or RequestFailed events.
NavigationResponseAsync() awaits this before reading the response, preventing
races where lifecycle events resolve the navigation before the response is
available.

Also fix LifecycleWatcher.Navigated to return early for BackForwardCacheRestore
(matching upstream behavior) instead of falling through to CheckLifecycleComplete.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant