Skip to content

Conversation

@aslushnikov
Copy link
Contributor

Browser registry is responsible for 3 things:

  1. Remove downloaded browsers if there are no packages that refer to them
  2. Install default browsers needed for the current package
  3. Install browsers on-demand when used through Playwright CLI

Currently, registry relies on a single "download" field in browsers.json
to carry both (1) and (2). However, browsers in (3) are marked as
download: false so that they aren't installed automatically in (2), so
auto-remove procedure in (1) removes them on subsequent installation.

One possible approach to fix this would be modifying package's browsers.json to
change download: false to true when browsers are installed with
Playwright CLI. This approach was explored here:
bc04a51

We decided against this since we have a history of issues related to
package modifications after NPM installation. This breaks all
sorts of yarn/npm caching mechanisms.

Instead, this patch is a two-step refactor:

  • remove the "download" field in browsers.json. Now, all registries
    (including old ones from previously-released versions) will retain any
    browsers that are mentioned in the browsers.json.
  • add a new flag "installByDefault", that is only used for default
    installation.

With this change, the registry tasks are done like this:

  • (1) auto-removal: if browser has a back reference, it is retained,
    otherwise it is removed from registry
  • (2) default installation: use only installByDefault to carry default installations
  • (3) CLI installation: simply installs browsers. Since we retain
    everythings that's referenced in (1), browsers aren't removed.

Fixes #5902

Browser registry is responsible for 3 things:
1. Remove downloaded browsers if there are no packages that refer to them
2. Install default browsers needed for the current package
3. Install browsers on-demand when used through Playwright CLI

Currently, registry relies on a single "download" field in `browsers.json`
to carry both (1) and (2). However, browsers in (3) are marked as
`download: false` so that they aren't installed automatically in (2), so
auto-remove procedure in (3) removes them on subsequent installation.

One possible approach to fix this would be modifying package's `browsers.json` to
change `download: false` to `true` when browsers are installed with
Playwright CLI. This approach was explored here:
microsoft@bc04a51

We decided against this since we have a history of issues related to
package modifications after NPM installation. This breaks all
sorts of yarn/npm caching mechanisms.

Instead, this patch is a two-step refactor:
- remove the "download" field in `browsers.json`. Now, all registries
(including old ones from previously-released versions) will retain any
browsers that are mentioned in the `browsers.json`.
- add a new flag "installByDefault", that is **only used** for default
installation.

With this change, the registry tasks are done like this:
- (1) auto-removal: if browser has a back reference, it is retained,
otherwise it is removed from registry
- (2) default installation: use only `installByDefault` to carry default installations
- (3) CLI installation: simply installs browsers. Since we retain
everythings that's referenced in (1), browsers aren't removed.

Fixes microsoft#5902
Copy link
Member

@yury-s yury-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I also like the description!

@aslushnikov aslushnikov merged commit 2064d27 into microsoft:master Mar 22, 2021
@aslushnikov aslushnikov deleted the registry-drop-download-field branch March 22, 2021 18:43
aslushnikov added a commit to aslushnikov/playwright that referenced this pull request Mar 22, 2021
…ft#5904)

Browser registry is responsible for 3 things:
1. Remove downloaded browsers if there are no packages that refer to them
2. Install default browsers needed for the current package
3. Install browsers on-demand when used through Playwright CLI

Currently, registry relies on a single "download" field in `browsers.json`
to carry both (1) and (2). However, browsers in (3) are marked as
`download: false` so that they aren't installed automatically in (2), so
auto-remove procedure in (1) removes them on subsequent installation.

One possible approach to fix this would be modifying package's `browsers.json` to
change `download: false` to `true` when browsers are installed with
Playwright CLI. This approach was explored here:
microsoft@bc04a51

We decided against this since we have a history of issues related to
package modifications after NPM installation. This breaks all
sorts of yarn/npm caching mechanisms.

Instead, this patch is a two-step refactor:
- remove the "download" field in `browsers.json`. Now, all registries
(including old ones from previously-released versions) will retain any
browsers that are mentioned in the `browsers.json`.
- add a new flag "installByDefault", that is **only used** for default
installation.

With this change, the registry tasks are done like this:
- (1) auto-removal: if browser has a back reference, it is retained,
otherwise it is removed from registry
- (2) default installation: use only `installByDefault` to carry default installations
- (3) CLI installation: simply installs browsers. Since we retain
everythings that's referenced in (1), browsers aren't removed.

Fixes microsoft#5902
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] browsers are eventually removed when installed with Playwright CLI

2 participants