fix: resolve navigation hang on Windows when using intercept with object mock - #2776
Conversation
…ect mock On Windows, Chrome sometimes skips Network.responseReceived and frameStoppedLoading CDP events after Fetch.fulfillRequest for Document navigations. This causes handleNavigation to wait forever on responsePromise and waitForNavigation to stall on unresolved frame promises. Fix: - fetchHandler: after fulfillRequest succeeds for a Document resource, emit a synthetic responseReceived event (unblocks handleNavigation) and a navigationFulfilledByIntercept event with the frameId - pageHandler: listen for navigationFulfilledByIntercept and explicitly resolve pending frameEvent and frameNavigationEvent promises Also adds taiko:intercept debug logging and restores retry wrappers on Windows CI with cleanup between attempts. Signed-off-by: winst0niuss <chumachenko.vadym@gmail.com>
Signed-off-by: winst0niuss <chumachenko.vadym@gmail.com>
…workId matching networkId from Fetch.requestPaused is optional and may be undefined on some platforms, causing the synthetic responseReceived to not match the requestId stored by handleNavigation. Replace with a dedicated event matched by URL. Signed-off-by: winst0niuss <chumachenko.vadym@gmail.com>
|
@winst0niuss Thank you for contributing to taiko. Your pull request has been labeled as a release candidate 🎉🎉. Merging this PR will trigger a release. Please bump up the version as part of this PR.Instructions to bump the version can found at CONTRIBUTING.md If the CONTRIBUTING.md file does not exist or does not include instructions about bumping up the version, please looks previous commits in git history to see what changes need to be done. |
Signed-off-by: winst0niuss <chumachenko.vadym@gmail.com>
|
The failure in Unit tests - windows-latest - 24 is unrelated to this PR. The process crashed mid-run with exit code 3221226505 (0xC0000409 — STATUS_STACK_BUFFER_OVERRUN), which is a Windows OS-level crash, not a test assertion failure. |
|
@winst0niuss looks like windows tests as still flaky? |
|
Tests are still flaky. I'm looking into it. |
- Add await focus(input) before write() in focused-element tests to make focus explicit rather than relying on autofocus, which is unreliable on Windows CI after goto(). - Use waitForNavigation: true in beforeEach goto() to guarantee DOM is ready before focus() — eliminates intermittent "TextBox not found" on slow ubuntu runners. - Add beforeEach goto() and explicit focus() to write with hideText block, aligning with upstream commit 428f73d. - Extract validateEmitterEvent handler to a named variable and remove the listener on timeout — prevents stale listeners from contaminating subsequent tests when a test times out. Backport of upstream stabilization commits 1068af6, d798ba2, 428f73d from getgauge/taiko branch update-chromium-149.0.7806.0. Signed-off-by: winst0niuss <chumachenko.vadym@gmail.com>
|
Windows write tests were stabilized in a dedicated branch (winst0niuss#3) and verified over 10 CI runs with no test-related failures. The fix is now in master: commit 479f7de. |
|
@zabil, re-run tests, pls |
Remove explicit focus() calls from 'into focused element' and 'should enter emoji char into focused element' tests. These tests verify that write() targets the element with default/autofocus, not one explicitly focused via focus(). The waitForNavigation: true in beforeEach is sufficient for CI stability (confirmed by 17 consecutive green runs). focus() is kept in the hideText block where it is necessary alongside beforeEach goto() to ensure the element exists on a fresh page. Signed-off-by: winst0niuss <chumachenko.vadym@gmail.com>
|
@zabil, all tests are green. |
Fixes the Windows navigation hang diagnosed in #2775.
What the debug logs showed
Using the
taiko:interceptlogging from #2775, captured this pattern for the second navigation:Fetch.fulfillRequestcompletes without error, so the hang is not a network or interceptor issue.Root cause
handleNavigation()inpageHandler.jsawaits aresponsePromisethat resolves only whenNetwork.responseReceivedfires with a matchingrequestId. On Windows, afterFetch.fulfillRequest, Chrome sometimes:Network.responseReceivedentirely —responsePromisenever resolvesframeStoppedLoading— a pendingframeEventpromise inwaitForNavigation'sPromise.all()never resolvesEither way, navigation times out after 60 seconds.
The first navigation (
/employees/1/address) avoids the race; the second hits it because Chrome's internal state is slightly different after the first completed navigation.Fix
fetchHandler.js— afterfulfillRequestresolves for aDocumentresource, emit two synthetic events:interceptedNavigationResponsewith the URL and response details — unblocksresponsePromiseinhandleNavigationvia URL matching (avoids relying onp.networkIdwhich is optional and may be undefined)navigationFulfilledByInterceptwithp.frameId— signalspageHandlerto resolve any pending frame promisespageHandler.js— two additions:handleNavigationnow also listens forinterceptedNavigationResponseand resolvesresponsePromisewhen the URL matches the navigation targetnavigationFulfilledByInterceptthat callsresolveFrameEventandresolveFrameNavigationEvent, allowingwaitForNavigationto proceed to thedocument.readyStatecheckAlso included
on_retry_command: taskkill /F /IM chrome.exe /Tfor unit tests to kill lingering Chrome processes between attempts and prevent cascade failureshandleNavigationupdated to reflect the newinterceptedNavigationResponselistenerChecks
Actions Run: View GitHub Actions Run