Skip to content

Commit 82a57ef

Browse files
authored
fix: The 'WebSocket connection closed' error on Chrome 130 (#8297)
<!-- Thank you for your contribution. Before making a PR, please read our contributing guidelines at https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution We recommend creating a *draft* PR, so that you can mark it as 'ready for review' when you are done. --> ## Purpose When requesting active tabs in Chrome 130.0.6723.6, a chrome-extension tab is included in the list. A CDP client is created based on this tab, but the tab gets closed, which results in the error. ## Approach Excluded tabs with `^chrome-extension` URLs from the list of tabs. ## References closes #8286 ## Pre-Merge TODO - [ ] Write tests for your proposed changes - [ ] Make sure that existing tests do not fail
1 parent 051ee10 commit 82a57ef

File tree

1 file changed

+7
-1
lines changed
  • src/browser/provider/built-in/dedicated/chrome/cdp-client

1 file changed

+7
-1
lines changed

src/browser/provider/built-in/dedicated/chrome/cdp-client/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import remoteChrome, { TargetInfo } from 'chrome-remote-interface';
22

33
const DEVTOOLS_TAB_URL_REGEX = /^devtools:\/\/devtools/;
4+
// NOTE: Github issue: https://github.com/DevExpress/testcafe/issues/8286
5+
const CHROME_EXTENSION_TAB_URL_REGEX = /^chrome-extension:\/\//;
6+
7+
function isInternalUrl (url: string): boolean {
8+
return DEVTOOLS_TAB_URL_REGEX.test(url) || CHROME_EXTENSION_TAB_URL_REGEX.test(url);
9+
}
410

511
export async function getTabs (port: number): Promise<TargetInfo[]> {
612
const tabs = await remoteChrome.List({ port });
713

8-
return tabs.filter(t => t.type === 'page' && !DEVTOOLS_TAB_URL_REGEX.test(t.url));
14+
return tabs.filter(t => t.type === 'page' && !isInternalUrl(t.url));
915
}
1016

1117
export async function getTabById (port: number, id: string): Promise<TargetInfo> {

0 commit comments

Comments
 (0)