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

This commit is contained in:
Yury Semikhatsky 2025-04-11 09:57:18 -07:00 committed by GitHub
parent ee073d6906
commit c9cd9dc1e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 9 deletions

View File

@ -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 });

View File

@ -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}`);
});
}

View File

@ -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) {