Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: rename *ConnectionTimeout to *SocketTimeout (#35583)

Yury Semikhatskyc9cd9dc1e484
diff --git a/packages/playwright-core/src/server/registry/browserFetcher.ts b/packages/playwright-core/src/server/registry/browserFetcher.ts
index 38a3e860c6..f912b2a2fe 100644
--- a/packages/playwright-core/src/server/registry/browserFetcher.ts
+++ b/packages/playwright-core/src/server/registry/browserFetcher.ts
@@ -30,7 +30,7 @@ import { browserDirectoryToMarkerFilePath } from '.';
import type { DownloadParams } from './oopDownloadBrowserMain';
-export async function downloadBrowserWithProgressBar(title: string, browserDirectory: string, executablePath: string | undefined, downloadURLs: string[], downloadFileName: string, downloadConnectionTimeout: number): Promise<boolean> {
+export async function downloadBrowserWithProgressBar(title: string, browserDirectory: string, executablePath: string | undefined, downloadURLs: string[], downloadFileName: string, downloadSocketTimeout: number): Promise<boolean> {
if (await existsAsync(browserDirectoryToMarkerFilePath(browserDirectory))) {
// Already downloaded.
debugLogger.log('install', `${title} is already downloaded.`);
@@ -44,7 +44,7 @@ export async function downloadBrowserWithProgressBar(title: string, browserDirec
debugLogger.log('install', `downloading ${title} - attempt #${attempt}`);
const url = downloadURLs[(attempt - 1) % downloadURLs.length];
logPolitely(`Downloading ${title}` + colors.dim(` from ${url}`));
- const { error } = await downloadBrowserWithProgressBarOutOfProcess(title, browserDirectory, url, zipPath, executablePath, downloadConnectionTimeout);
+ const { error } = await downloadBrowserWithProgressBarOutOfProcess(title, browserDirectory, url, zipPath, executablePath, downloadSocketTimeout);
if (!error) {
debugLogger.log('install', `SUCCESS installing ${title}`);
break;
@@ -75,7 +75,7 @@ export async function downloadBrowserWithProgressBar(title: string, browserDirec
* Thats why we execute it in a separate process and check manually if the destination file exists.
* https://github.com/microsoft/playwright/issues/17394
*/
-function downloadBrowserWithProgressBarOutOfProcess(title: string, browserDirectory: string, url: string, zipPath: string, executablePath: string | undefined, connectionTimeout: number): Promise<{ error: Error | null }> {
+function downloadBrowserWithProgressBarOutOfProcess(title: string, browserDirectory: string, url: string, zipPath: string, executablePath: string | undefined, socketTimeout: number): Promise<{ error: Error | null }> {
const cp = childProcess.fork(path.join(__dirname, 'oopDownloadBrowserMain.js'));
const promise = new ManualPromise<{ error: Error | null }>();
const progress = getDownloadProgress();
@@ -108,7 +108,7 @@ function downloadBrowserWithProgressBarOutOfProcess(title: string, browserDirect
url,
zipPath,
executablePath,
- connectionTimeout,
+ socketTimeout,
userAgent: getUserAgent(),
};
cp.send({ method: 'download', params: downloadParams });
diff --git a/packages/playwright-core/src/server/registry/index.ts b/packages/playwright-core/src/server/registry/index.ts
index c3e51e391b..1911740360 100644
--- a/packages/playwright-core/src/server/registry/index.ts
+++ b/packages/playwright-core/src/server/registry/index.ts
@@ -1188,9 +1188,11 @@ export class Registry {
: `${displayName} playwright build v${descriptor.revision}`;
const downloadFileName = `playwright-download-${descriptor.name}-${hostPlatform}-${descriptor.revision}.zip`;
- const downloadConnectionTimeoutEnv = getFromENV('PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT');
- const downloadConnectionTimeout = +(downloadConnectionTimeoutEnv || '0') || 30_000;
- await downloadBrowserWithProgressBar(title, descriptor.dir, executablePath, downloadURLs, downloadFileName, downloadConnectionTimeout).catch(e => {
+ // PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT is a misnomer, it actually controls the socket's
+ // max idle timeout. Unfortunately, we cannot rename it without breaking existing user workflows.
+ const downloadSocketTimeoutEnv = getFromENV('PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT');
+ const downloadSocketTimeout = +(downloadSocketTimeoutEnv || '0') || 30_000;
+ await downloadBrowserWithProgressBar(title, descriptor.dir, executablePath, downloadURLs, downloadFileName, downloadSocketTimeout).catch(e => {
throw new Error(`Failed to download ${title}, caused by\n${e.stack}`);
});
}
diff --git a/packages/playwright-core/src/server/registry/oopDownloadBrowserMain.ts b/packages/playwright-core/src/server/registry/oopDownloadBrowserMain.ts
index 770a6334fe..c0619d95e4 100644
--- a/packages/playwright-core/src/server/registry/oopDownloadBrowserMain.ts
+++ b/packages/playwright-core/src/server/registry/oopDownloadBrowserMain.ts
@@ -27,7 +27,7 @@ export type DownloadParams = {
url: string;
zipPath: string;
executablePath: string | undefined;
- connectionTimeout: number;
+ socketTimeout: number;
userAgent: string;
};
@@ -54,7 +54,7 @@ function downloadFile(options: DownloadParams): Promise<void> {
headers: {
'User-Agent': options.userAgent,
},
- timeout: options.connectionTimeout,
+ timeout: options.socketTimeout,
}, response => {
log(`-- response status code: ${response.statusCode}`);
if (response.statusCode !== 200) {