Skip to content

fix: resolve navigation hang on Windows when using intercept with object mock - #2776

Merged
zabil merged 6 commits into
getgauge:masterfrom
winst0niuss:master
Apr 29, 2026
Merged

zabil merged 6 commits into
getgauge:masterfrom
winst0niuss:master

Conversation

@winst0niuss

@winst0niuss winst0niuss commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Fixes the Windows navigation hang diagnosed in #2775.

What the debug logs showed

Using the taiko:intercept logging from #2775, captured this pattern for the second navigation:

requestPaused url=https://localhost/employees/2/address    ✓ CDP event fired
matched interceptor ...                                    ✓ interceptor found
calling fulfillRequest (object) responseCode=200           ✓ called, no error
--- silence for 60 seconds ---
Navigation took more than 60000ms                          ✗ timeout

Fetch.fulfillRequest completes without error, so the hang is not a network or interceptor issue.

Root cause

handleNavigation() in pageHandler.js awaits a responsePromise that resolves only when Network.responseReceived fires with a matching requestId. On Windows, after Fetch.fulfillRequest, Chrome sometimes:

  1. Skips Network.responseReceived entirely — responsePromise never resolves
  2. Skips frameStoppedLoading — a pending frameEvent promise in waitForNavigation's Promise.all() never resolves

Either 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 — after fulfillRequest resolves for a Document resource, emit two synthetic events:

  • interceptedNavigationResponse with the URL and response details — unblocks responsePromise in handleNavigation via URL matching (avoids relying on p.networkId which is optional and may be undefined)
  • navigationFulfilledByIntercept with p.frameId — signals pageHandler to resolve any pending frame promises

pageHandler.js — two additions:

  • handleNavigation now also listens for interceptedNavigationResponse and resolves responsePromise when the URL matches the navigation target
  • Module-level listener for navigationFulfilledByIntercept that calls resolveFrameEvent and resolveFrameNavigationEvent, allowing waitForNavigation to proceed to the document.readyState check

Also included

  • Windows CI: retry wrappers restored (removed temporarily during diagnosis to expose the failure signal, now restored for infrastructure flakiness unrelated to this fix); added on_retry_command: taskkill /F /IM chrome.exe /T for unit tests to kill lingering Chrome processes between attempts and prevent cascade failures
  • Unit test for handleNavigation updated to reflect the new interceptedNavigationResponse listener

Checks

Actions Run: View GitHub Actions Run

…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>
@gaugebot

gaugebot Bot commented Apr 28, 2026

Copy link
Copy Markdown

@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>
@winst0niuss

Copy link
Copy Markdown
Contributor Author

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.
Re-run should resolve it.

@zabil

zabil commented Apr 28, 2026

Copy link
Copy Markdown
Member

@winst0niuss looks like windows tests as still flaky?

@winst0niuss

Copy link
Copy Markdown
Contributor Author

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>
@winst0niuss

Copy link
Copy Markdown
Contributor Author

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.

@winst0niuss

Copy link
Copy Markdown
Contributor Author

@zabil, re-run tests, pls

Comment thread tests/unit-tests/write.test.js Outdated
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>
@winst0niuss

Copy link
Copy Markdown
Contributor Author

@zabil, all tests are green.
check pls

@zabil
zabil merged commit 3e0c969 into getgauge:master Apr 29, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants