playwright: [BUG] Google Cloud Function error (deploy)
Context:
- Operating System: Linux
- Node version: Node.js 10
- Browser: Webkit
- Extra: [any specific details about your environment]
Code Snippet
const {chromium, webkit, firefox} = require('playwright');
(async () => {
const browser = await webkit.launch({ headless: true });
const context = await browser.newContext();
const page = await context.newPage();
})();
Describe the bug
I’m trying to deploy my playwright application in Google Cloud Functions. It seems like there is a problem to spawn the browser.
Error: function terminated. Recommended action: inspect logs for termination reason. Details:
Failed to launch browser: Error: spawn /root/.cache/ms-playwright/chromium-764964/chrome-linux/chrome ENOENT
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16
I can confirm that the above solution works well. Thank you for sharing this !
Here is a complete example that returns a screenshot of google when queried. (Using NodeJS 14, 2GB RAM, latest chrome-aws-lambda version)
package.jsonindex.jsI’m currently using:
Without issues (I had issues when the major version was different).
Pseudo code:
Your approach seems promising as well, not sure why the shared library is missing.
This seems to work well now (I have only tested with playwright-chromium).
Only initial issue was that the launch method did not find the executable:
browserType.launch: Failed to launch chromium because executable doesn’t exist at /root/.cache/ms-playwright/chromium-888113/chrome-linux/chrome
Setting the environment variable PLAYWRIGHT_BROWSERS_PATH=0 resolved this, and I can now use playwright-chromium in Google Cloud Function to e.g. generate pdf 😃
Cheers -jo
BTW - had to raise memory limit to 1 GB to avoid running out of memory…