SeleniumHQ / SeleniumHQ/selenium
[🐛 Bug]: network.continueRequest() hangs navigation in Chrome
- Dominant language
- Java
- Stars
- 34.5k
- Forks
- 8.7k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 92
Description
### 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
```shell
/**
* 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
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
```
Contributor guide
Assessment
This issue has not been assessed yet.