Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Playwright post-install script to fix chrome binary sometimes unavailable #142

Closed
andrewvc opened this issue Nov 18, 2020 · 1 comment · Fixed by #147
Closed

Run Playwright post-install script to fix chrome binary sometimes unavailable #142

andrewvc opened this issue Nov 18, 2020 · 1 comment · Fixed by #147
Assignees
Labels
bug Something isn't working

Comments

@andrewvc
Copy link
Contributor

andrewvc commented Nov 18, 2020

It seems that sometimes the synthetics package can get into a state where our code runs, but the version of the playwright library used references a chrome version that is not installed. @paulb-elastic got his system in such a state once, but we couldn't repro it.

My hunch is this can happen on only some systems after playwright releases a new version. I'm somewhat unsure beyond that, since my system can't repro this.

My hunch is that it would be a good thing to run the playwright post-install script on each run to ensure that the chrome binary is present, and attempt download if not. I can't think of a reason not to try downloading it vs. a straight-up failure.

This only seems to happen with npx running a globally installed package. For a local project this circumstance can be fixed with npm i && npm install playwright. See microsoft/playwright#3712 for more context on that situation

@andrewvc andrewvc added the bug Something isn't working label Nov 18, 2020
@vigneshshanmugam
Copy link
Member

vigneshshanmugam commented Nov 24, 2020

After some analysis, I would not call this a bug in our package. Instead it's a result of how our examples work at the moment with heartbeat.

  • Our docker image installs the latest version of @elastic/synthetics@alpha package which installs the chromium browser on specified global location, in heartbeat this would be in /usr/share/heartbeat/.cache/ms-playwright/chromium-<version>.

  • Now, when heartbeat runs, it will cd in to our examples/todos directory and installs the dependencies specified in package.json

    "@elastic/synthetics": "^0.0.1-alpha.6",

  • On every scheduled interval, heartbeat runs the examples with already installed node_modules, As both of the global/local @elastic/synthetics packages use the global ms-playwright cache directory for launching chromium, any intermediate state of updating one or the other would always end up in the issue mentioned above.

Solutions

There are multiple solutions to this problem

  1. Use hermetic install of playwright for examples/todos as it would install the browsers under node_modules/.local_browsers/chromium-<version> and would not use the global package under any circumstance. This can be achieved by setting ENV PLAYWRIGHT_BROWSERS_PATH=0

  2. Use the same version of @elastic/synthetics in the example also like how we did before. This means we have to modify the todos/package.json to use file urls.

  3. wipe out the global docker npm cache and always point to the latest version in examples/todos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants