[🐛 Bug]: network.continueRequest() hangs navigation in Chrome

Open
#17,373 6 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript, node.js

Research direction

Start by running test/chrome-bug/index.js with the reported Chrome version and compare its output with Firefox. Trace the network.beforeRequestSent() and network.continueRequest() entry points shown in the reproduction. Done means Chrome navigation completes after the intercepted request is continued with the added header, without regressing Firefox.

Written by the indexing model from the issue text.

Description

C-nodejs D-chrome I-defect OS-mac
Description

When intercepting a request in network.beforeRequestSent() and calling network.continueRequest(), Chrome hangs on navigation.
The same script works correctly in Firefox.

My Chrome version: 147.0.7727.117 (Official Build) (arm64)

Reproducible Code
/**
 * Reproduction of the bug in Chrome with network interception.
 * Usage:
 * node test/chrome-bug/index.js
 */

import { before, after, it } from 'node:test';
import { setTimeout as delay } from 'timers/promises';
import { Builder } from 'selenium-webdriver';
import { Network as getNetwork } from 'selenium-webdriver/bidi/network.js';
import chrome from 'selenium-webdriver/chrome.js';
import firefox from 'selenium-webdriver/firefox.js';
import { Header, BytesValue } from 'selenium-webdriver/bidi/networkTypes.js';
import { AddInterceptParameters } from 'selenium-webdriver/bidi/addInterceptParameters.js';
import { ContinueRequestParameters } from 'selenium-webdriver/bidi/continueRequestParameters.js';
import { InterceptPhase } from 'selenium-webdriver/bidi/interceptPhase.js';

const driver = await new Builder()
  .forBrowser('chrome')
  .setChromeOptions(new chrome.Options().enableBidi())
  // Uncomment to check with firefox
  // .forBrowser('firefox')
  // .setFirefoxOptions(new firefox.Options().enableBidi())
  .build();

const network = await getNetwork(driver);

const url = 'https://httpbin.org/headers';

await network.addIntercept(
  new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT).urlStringPattern(url),
);

await network.beforeRequestSent(async (event) => {
  const request = event.request;
  const requestId = request.request;
  console.log('Intercepted request:', request.url, requestId);
  const params = new ContinueRequestParameters(requestId).headers([
    ...request.headers,
    new Header('X-Test-Header', new BytesValue('string', 'TestValue')),
  ]);
  await network.continueRequest(params);
});

await driver.get(url);
Debugging Logs
Logs when using Chrome:

node test/chrome-bug/index.js
Intercepted request: https://httpbin.org/headers C591722C28CC191789B1E6978DDC1B79
^C


Logs when using Firefox:

node test/chrome-bug/index.js
Intercepted request: https://httpbin.org/headers 11-3038625a-6b4d-4704-9e1c-096a4119c324
Intercepted request: https://httpbin.org/favicon.ico 35-3038625a-6b4d-4704-9e1c-096a4119c324
^C
Dominant language
Java
Stars
34.6k
Forks
8.7k
Avg merge
1d 16h
Merged PRs (30d)
107

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SeleniumHQ/selenium

All issues in SeleniumHQ/selenium

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.