mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	chore: add ESRP CDN for browser downloads (#33585)
This commit is contained in:
		
							parent
							
								
									b8f824ca6b
								
							
						
					
					
						commit
						358fad45cd
					
				@ -36,7 +36,7 @@ export async function downloadBrowserWithProgressBar(title: string, browserDirec
 | 
			
		||||
 | 
			
		||||
  const zipPath = path.join(os.tmpdir(), downloadFileName);
 | 
			
		||||
  try {
 | 
			
		||||
    const retryCount = 3;
 | 
			
		||||
    const retryCount = 5;
 | 
			
		||||
    for (let attempt = 1; attempt <= retryCount; ++attempt) {
 | 
			
		||||
      debugLogger.log('install', `downloading ${title} - attempt #${attempt}`);
 | 
			
		||||
      const url = downloadURLs[(attempt - 1) % downloadURLs.length];
 | 
			
		||||
 | 
			
		||||
@ -37,16 +37,23 @@ const PACKAGE_PATH = path.join(__dirname, '..', '..', '..');
 | 
			
		||||
const BIN_PATH = path.join(__dirname, '..', '..', '..', 'bin');
 | 
			
		||||
 | 
			
		||||
const PLAYWRIGHT_CDN_MIRRORS = [
 | 
			
		||||
  'https://playwright.azureedge.net/dbazure/download/playwright', // ESRP CDN
 | 
			
		||||
  'https://playwright.download.prss.microsoft.com/dbazure/download/playwright', // Directly hit ESRP CDN
 | 
			
		||||
 | 
			
		||||
  // Old endpoints which hit the Storage Bucket directly:
 | 
			
		||||
  'https://playwright.azureedge.net',
 | 
			
		||||
  'https://playwright-akamai.azureedge.net',
 | 
			
		||||
  'https://playwright-verizon.azureedge.net',
 | 
			
		||||
  'https://playwright-akamai.azureedge.net',  // Actually Edgio which will be retired Q4 2025.
 | 
			
		||||
  'https://playwright-verizon.azureedge.net', // Actually Edgio which will be retired Q4 2025.
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
if (process.env.PW_TEST_CDN_THAT_SHOULD_WORK) {
 | 
			
		||||
  for (let i = 0; i < PLAYWRIGHT_CDN_MIRRORS.length; i++) {
 | 
			
		||||
    const cdn = PLAYWRIGHT_CDN_MIRRORS[i];
 | 
			
		||||
    if (cdn !== process.env.PW_TEST_CDN_THAT_SHOULD_WORK)
 | 
			
		||||
      PLAYWRIGHT_CDN_MIRRORS[i] = cdn + '.does-not-resolve.playwright.dev';
 | 
			
		||||
    if (cdn !== process.env.PW_TEST_CDN_THAT_SHOULD_WORK) {
 | 
			
		||||
      const parsedCDN = new URL(cdn);
 | 
			
		||||
      parsedCDN.hostname = parsedCDN.hostname + '.does-not-resolve.playwright.dev';
 | 
			
		||||
      PLAYWRIGHT_CDN_MIRRORS[i] = parsedCDN.toString();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,8 @@ import net from 'net';
 | 
			
		||||
import type { AddressInfo } from 'net';
 | 
			
		||||
 | 
			
		||||
const CDNS = [
 | 
			
		||||
  'https://playwright.azureedge.net/dbazure/download/playwright', // ESRP
 | 
			
		||||
  'https://playwright.download.prss.microsoft.com/dbazure/download/playwright', // ESRP Fallback
 | 
			
		||||
  'https://playwright.azureedge.net',
 | 
			
		||||
  'https://playwright-akamai.azureedge.net',
 | 
			
		||||
  'https://playwright-verizon.azureedge.net',
 | 
			
		||||
@ -90,8 +92,8 @@ test(`npx playwright install should not hang when CDN closes the connection`, as
 | 
			
		||||
      },
 | 
			
		||||
      expectToExitWithError: true
 | 
			
		||||
    });
 | 
			
		||||
    expect(retryCount).toBe(3);
 | 
			
		||||
    expect([...result.matchAll(/Download failed: server closed connection/g)]).toHaveLength(3);
 | 
			
		||||
    expect(retryCount).toBe(5);
 | 
			
		||||
    expect([...result.matchAll(/Download failed: server closed connection/g)]).toHaveLength(5);
 | 
			
		||||
  } finally {
 | 
			
		||||
    await new Promise(resolve => server.close(resolve));
 | 
			
		||||
  }
 | 
			
		||||
@ -120,8 +122,8 @@ test(`npx playwright install should not hang when CDN TCP connection stalls`, as
 | 
			
		||||
      },
 | 
			
		||||
      expectToExitWithError: true
 | 
			
		||||
    });
 | 
			
		||||
    expect(retryCount).toBe(3);
 | 
			
		||||
    expect([...result.matchAll(/timed out after/g)]).toHaveLength(3);
 | 
			
		||||
    expect(retryCount).toBe(5);
 | 
			
		||||
    expect([...result.matchAll(/timed out after/g)]).toHaveLength(5);
 | 
			
		||||
  } finally {
 | 
			
		||||
    for (const socket of socketsToDestroy)
 | 
			
		||||
      socket.destroy();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user