From 344bc2af62e4068fe2cb8162d4b6c8242aac843b Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Tue, 24 Jan 2023 17:28:00 +0100 Subject: [PATCH] fix: don't clean up previous browser versions (#9568) Since we moved to the central binaries cache it does not make sense to clean up old binaries automatically because multiple installations can use different versions. We expect the users to clean the cache from time to time until we offer a CLI for managing the browsers. Closes #9533 --- .../puppeteer-core/src/node/BrowserFetcher.ts | 7 +++++++ packages/puppeteer/src/node/install.ts | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/puppeteer-core/src/node/BrowserFetcher.ts b/packages/puppeteer-core/src/node/BrowserFetcher.ts index 493518ad5e0..c96b327045f 100644 --- a/packages/puppeteer-core/src/node/BrowserFetcher.ts +++ b/packages/puppeteer-core/src/node/BrowserFetcher.ts @@ -504,6 +504,13 @@ export class BrowserFetcher { #getFolderPath(revision: string): string { return path.resolve(this.#downloadPath, `${this.#platform}-${revision}`); } + + /** + * @internal + */ + getDownloadPath(): string { + return this.#downloadPath; + } } function parseFolderPath( diff --git a/packages/puppeteer/src/node/install.ts b/packages/puppeteer/src/node/install.ts index 25b317058ef..8011e02e97e 100644 --- a/packages/puppeteer/src/node/install.ts +++ b/packages/puppeteer/src/node/install.ts @@ -94,13 +94,18 @@ export async function downloadBrowser(): Promise { logPolitely( `${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}` ); - localRevisions = localRevisions.filter(revision => { + const otherRevisions = localRevisions.filter(revision => { return revision !== revisionInfo.revision; }); - const cleanupOldVersions = localRevisions.map(revision => { - return browserFetcher.remove(revision); - }); - Promise.all([...cleanupOldVersions]); + if (otherRevisions.length) { + logPolitely( + `Other installed ${ + supportedProducts[product] + } browsers in ${browserFetcher.getDownloadPath()} include: ${otherRevisions.join( + ', ' + )}. Remove old revisions from ${browserFetcher.getDownloadPath()} if you don't need them.` + ); + } } function onError(error: Error) {