jupiterone / playwright-aws-lambda Goto Github PK
View Code? Open in Web Editor NEWSupport for running Microsoft's Playwright on AWS Lambda and Google Cloud Functions
License: MIT License
Support for running Microsoft's Playwright on AWS Lambda and Google Cloud Functions
License: MIT License
Code snippet:
try {
const browser = await launchChromium({ headless: true })
const page = await browser.newPage({
viewport: {
width: 868,
height: 500,
},
})
const nextURL = new URL(url)
await page.goto(nextURL.toString())
const { getHeaderTemplate, getFooterTemplate, margin } = templates[type]
const [headerTemplate, footerTemplate] = await Promise.all([
getHeaderTemplate(templateProps),
getFooterTemplate(templateProps),
])
const buffer = await page.pdf({
displayHeaderFooter: true,
headerTemplate,
footerTemplate,
margin,
printBackground: true,
})
const compressed = zlib.gzipSync(buffer)
const contentEncoding = 'gzip'
const filename = 'filename.pdf'
const s3Key = 'mykey/'.concat(filename)
const contentType = 'application/pdf'
const putObjectParams = {
Bucket: s3Bucket,
Key: `public/${s3Key}`,
ContentType: contentType,
ContentEncoding: contentEncoding,
Body: compressed,
}
await Promise.all([s3.putObject(putObjectParams).promise(), browser.close()])
return {
statusCode: 200,
headers: defaultHeaders,
body: {
s3Key,
filename,
contentType,
contentEncoding,
},
}
} catch (error) {
console.error(error)
return {
statusCode: 500,
headers: defaultHeaders,
body: { error: error.message },
}
}
Further explanation:
Help & Guidance please.
Thanks a bunch for creating this awesome package.
I was having an issue with the download event. It works great when I try to execute my code locally (serverless invoke local
) but when I deploy this via serverless deploy
, the waitForEvent('download')
times out.
Here's the code:
const { page, browser } = await openWebpage(URL);
const [download] = await Promise.all([
// Start waiting for the download
page.waitForEvent('download'),
// Perform the action that initiates download
page.click(`#${BTN_ID}`),
]);
Here's the openWebpage function:
export async function openWebpage(url) {
const browser = await playwright.launchChromium();
const context = await browser.newContext({
acceptDownloads: true,
});
const page = await context.newPage();
await page.goto(url);
return { page, browser: context };
}
A similar issue was posted in playwright's official repo here.
In that same issue, I've commented about my issue as well, here.
I guess since this package was created based on chrome-aws-lambda, which is for puppeteer basically, and puppeteer does not support download event, so it wasn't included in this package as well. But that's just a random guess. I'd love to help in any way to get this issue fixed.
Hope to hear from you soon.
I am following the example, creating a browser with await playwright.launchChromium({})
and then creating a context and context.newPage.
I always get this error: "Target page, context or browser has been closed"
Hello,
I use the package to generate screenshot for various links and webpages. I am getting an issue rendering Emojis, as whenever I take a SS, the emojis are all turned to boxes. Do I need to install any specific plugin or anything
The current contained Chromium version is quite outdated, since Playwright relies on the latest features, it would be good to update it to the latest Beta or Canary.
I have tried specifying a port using "--remote-debugging-port=9222" as an option which works locally. However when deployed to vercel the option causes an error.
However all I need is to know the actual port chromium has opened on as I want to run lighthouse.
Any idea how I can get at it?
Thank you
I would really love to use all browser types in lambda. Would it be possible to add them?
I'm deploying a NodejsFunction, and I'm getting this error invoking my lambda:
ENOENT: no such file or directory, open '/var/task/bin/chromium.br
NodejsFunction uses esbuild that compresses the lambda code. Therefore, missing chromium binaries.
Is anyone doing something similar with a NodejsFunction
that could share some snippets?
I am getting blank PDF pages when deployed to LAMBDA but it works fine locally.
What's interesting is that the PDF pages although they are blank, they have the correct amount of pages.
I am not doing anything fancy:
`
this.browser = await playwright.launchChromium({
headless: true
});
this.ctx = await this.browser.newContext();
const page = await this.ctx.newPage();
await page.goto(url);
pdf = await page.pdf();
`
It's running on expressjs, deployed with serverless. I get no error, I get a valid PDF buffer back. I am able to open the PDF file, but the pages are always blank.
Hello,
Our use case basically needs a OAuth Login like Chrome or facebook for a complete E2E testing.
We are using playwright and running it on lambda. The Normal Login works fine but the OAuth fails due to the headless mode. I found out the package puppeteer-extra-plugin-stealth
which is used to bypass bot protection for OAuth.
Is there any way we can use the same plugin in playwright as its a fork from puppeteer?
Thank you for this library, I have found playwright to be superior to puppeteer and would prefer to use it on AWS.
Unfortunately currently I am getting an error whenever I try to use it, including the simple demo code in the README.
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'playwright-core'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (E:\Nodejs\AllTheComps\playwright\dev\node_modules\playwright-aws-lambda\dist\src\chromium.js:5:20)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
The offending line is:
const playwright = require("playwright-core");
I'm developing on Windows but this happened on Lambda as well. I have npm install'd playwright-core
, it definitely exists in node_modules
Docs allude to this. Does support for Google Cloud Functions exist as part of this package? Perhaps it supports currently, but the package naming is confusing.
Is there any plan to add support for Node20.x? If yes, when?
and If not, what would be the best package to replace this?
Thanks.
Is there a plan to provide a Lambda Layer? It would be more efficient than packing chromium with every update to the code.
Whenever I try to keep the browser open between invocations, it seems like the browser gets closed/killed.
This is the error I'm getting after the first invocation:
{
"name": "Error",
"stack": [
": Protocol error (Target.createTarget): Browser closed.",
"==================== Browser output: ====================",
"[pid=25][err] #2 0x5652544896c5 (/tmp/chromium+0x48e46c4)",
"[pid=25][err] #3 0x7fa34c9137e0 (/usr/lib64/libpthread-2.26.so+0x117df)",
"[pid=25][err] #4 0x7fa34bbf0c20 __GI_raise",
"[pid=25][err] #5 0x7fa34bbf20c8 __GI_abort",
"[pid=25][err] #6 0x565254488625 (/tmp/chromium+0x48e3624)",
"[pid=25][err] #7 0x56525440a1c2 (/tmp/chromium+0x48651c1)",
"[pid=25][err] #8 0x5652534b3c78 (/tmp/chromium+0x390ec77)",
"[pid=25][err] #9 0x56525358908d (/tmp/chromium+0x39e408c)",
"[pid=25][err] #10 0x56525331b28b (/tmp/chromium+0x377628a)",
"[pid=25][err] #11 0x56525331b1b6 (/tmp/chromium+0x37761b5)",
"[pid=25][err] #12 0x5652535cdd21 (/tmp/chromium+0x3a28d20)",
"[pid=25][err] #13 0x5652535c2ec4 (/tmp/chromium+0x3a1dec3)",
"[pid=25][err] #14 0x5652535c2bc4 (/tmp/chromium+0x3a1dbc3)",
"[pid=25][err] #15 0x565255b3dba9 (/tmp/chromium+0x5f98ba8)",
"[pid=25][err] #16 0x565254583287 (/tmp/chromium+0x49de286)",
"[pid=25][err] #17 0x565255b49c8a (/tmp/chromium+0x5fa4c89)",
"[pid=25][err] #18 0x565255b49e09 (/tmp/chromium+0x5fa4e08)",
"[pid=25][err] #19 0x5652529f9b2d (/tmp/chromium+0x2e54b2c)",
"[pid=25][err] #20 0x5652529f5db8 (/tmp/chromium+0x2e50db7)",
"[pid=25][err] #21 0x565253e289b3 (/tmp/chromium+0x42839b2)",
"[pid=25][err] #22 0x565255b482f8 (/tmp/chromium+0x5fa32f7)",
"[pid=25][err] #23 0x565255b47598 (/tmp/chromium+0x5fa2597)",
"[pid=25][err] #24 0x5652532236ae (/tmp/chromium+0x367e6ad)",
"[pid=25][err] #25 0x5652532232b6 (/tmp/chromium+0x367e2b5)",
"[pid=25][err] #26 0x56525321f780 (/tmp/chromium+0x367a77f)",
"[pid=25][err] #27 0x565254438eeb (/tmp/chromium+0x4893eea)",
"[pid=25][err] #28 0x56525444982e (/tmp/chromium+0x48a482d)",
"[pid=25][err] #29 0x5652544495c0 (/tmp/chromium+0x48a45bf)",
"[pid=25][err] #30 0x5652544a4629 (/tmp/chromium+0x48ff628)",
"[pid=25][err] #31 0x565254449db5 (/tmp/chromium+0x48a4db4)",
"[pid=25][err] #32 0x565254426dae (/tmp/chromium+0x4881dad)",
"[pid=25][err] #33 0x5652531a3dd4 (/tmp/chromium+0x35fedd3)",
"[pid=25][err] #34 0x5652531a57d2 (/tmp/chromium+0x36007d1)",
"[pid=25][err] #35 0x565255b45fc6 (/tmp/chromium+0x5fa0fc5)",
"[pid=25][err] #36 0x56525439c794 (/tmp/chromium+0x47f7793)",
"[pid=25][err] #37 0x56525439c417 (/tmp/chromium+0x47f7416)",
"[pid=25][err] #38 0x565255996641 (/tmp/chromium+0x5df1640)",
"[pid=25][err] #39 0x565254395801 (/tmp/chromium+0x47f0800)",
"[pid=25][err] #40 0x5652543f549d (/tmp/chromium+0x485049c)",
"[pid=25][err] #41 0x5652543f51bc (/tmp/chromium+0x48501bb)",
"[pid=25][err] #42 0x7fa34bbde0ba __libc_start_main",
"[pid=25][err] #43 0x56525257fa2a _start",
"[pid=25][err] r8: 0000000000000000 r9: 00007ffe792bfa70 r10: 0000000000000008 r11: 0000000000000246",
"[pid=25][err] r12: 00007ffe792c0e50 r13: 00007ffe792bfd10 r14: 00007ffe792c0e58 r15: aaaaaaaaaaaaaaaa",
"[pid=25][err] di: 0000000000000002 si: 00007ffe792bfa70 bp: 00007ffe792bfcc0 bx: 0000000000000006",
"[pid=25][err] dx: 0000000000000000 ax: 0000000000000000 cx: 00007fa34bbf0c20 sp: 00007ffe792bfa70",
"[pid=25][err] ip: 00007fa34bbf0c20 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000",
"[pid=25][err] trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000",
"[pid=25][err] [end of stack trace]",
"[pid=25][err] Calling _exit(1). Core file will not be generated.",
" at captureStackTrace (/var/task/node_modules/playwright-core/lib/utils/stackTrace.js:60:17)",
" at BrowserContext._wrapApiCall (/var/task/node_modules/playwright-core/lib/client/channelOwner.js:101:58)",
" at BrowserContext.newPage (/var/task/node_modules/playwright-core/lib/client/browserContext.js:237:17)",
" at Runtime.exports.handler (/var/task/index.js:31:30)"
]
}
This is roughly the code I'm using:
const browser = require('playwright-aws-lambda').launchChromium()
exports.handler = async (event, options) => {
options.callbackWaitsForEmptyEventLoop = false
const context = await (await browser).newContext()
const page = await context.newPage()
await page.goto(event.url || 'https://example.com')
console.log('Page title: ', await page.title())
}
Do you know if this is a limitation of Lambda, or is there something else going on here? ๐ค
Maybe related issue: microsoft/playwright#2522
That too: vercel/og-image#52
Hi There,
I am runing playwright in AWS lambda using this package, it is great.
The page which I testing is very slow, how can I increase the default timeout, so that I still wait for the page loading.
Timeout 30000ms exceeded.
Tried integrating playwright-aws-lambda with an existing project and got an error, so went back to basics, started a new npm project and followed the steps in the README as follows:
npm install playwright-core playwright-aws-lambda --save
nodejs12.x
runtime.When running the lambda I get the following error:
ERROR Invoke Error {"errorType":"TypeError","errorMessage":"Cannot read property 'launch' of undefined","stack":
["TypeError: Cannot read property 'launch' of undefined"," at Object.launchChromium (/var/task/node_modules/playwright-
aws-lambda/dist/src/chromium.js:90:47)"," at processTicksAndRejections (internal/process/task_queues.js:97:5)"," at
async Runtime.exports.handler (/var/task/index.js:8:21)"]}
Apologies if this is user error. I did some research before logging this to see if there was an obvious fix, and simplified the repro process by using the bare minimum example code instead of my own code.
hi,
I'm using page.on('request'.. to check request parameters. Locally everything runs with on issue, logging the Login/Login post body with no issues. But when deployed on AWS Lambda the body is null. Using the code bellow.
versions:
"playwright-aws-lambda": "^0.6.0",
"playwright-core": "^1.7.1"
'use strict';
const playwright = require('playwright-aws-lambda');
module.exports.plTest = async event => {
let browser = null;
try {
const browser = await playwright.launchChromium();
const context = await browser.newContext();
const page = await context.newPage();
page.on('request', request=> {
let url = request.url();
let requestHeaders = request.headers();
let body = request.postData();
let body2 = request.postDataJSON();
let method = request.method();
console.log("URL: ",url);
console.log(`${method} body: `,body);
console.log(`${method} body2: `,body2);
console.log("\n\n");
});
await page.goto('https://dashboard.sleeknote.com/login');
const startUrl = await page.url();
console.log("Fill in user email");
await page.fill("#email", "[email protected]");
console.log("Fill in user password");
await page.fill("#password", "ZZZ1ZZ2ZZ3");
page.waitForTimeout(3000);
console.log("Click submit button");
await page.click('[type="submit"]');
page.waitForSelector(".dashboard");
console.log("Assert user is inside dashboard");
const currentUrl = await page.url();
console.log("currentUrl: ", currentUrl);
console.log('Page title: ', await page.title());
} catch (error) {
throw error;
} finally {
if (browser) {
await browser.close();
}
}
return {
statusCode: 200,
body: JSON.stringify(
{
message: 'Go Serverless v1.0! Your function executed successfully!',
input: event,
},
null,
2
),
};
};
We recently upgraded nodejs to 18.x but hit following errors
/tmp/chromium: error while libraries: shared file: No such file libnss3.so: cannot open shared object or directory
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.Error
Downgrading it to 16.x solved the issues.
--
I have a small express API that runs a scraper on Instagram that gets the ImgURL and descriptionText, I have moved this over to aws lambda as I was originally trying to run this on a Vercel serverless function. The function can run but takes longer than 10 seconds, which times out on the free version. Any help is appreciated., I keep timing out.
const playwright = require('playwright-aws-lambda');
exports.handler = async (event) => {
const link = event.link;
if (!link.includes('instagram')) {
throw new Error('Not an Instagram link');
}
try {
const browser = await playwright.launchChromium({headless: true});
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(link);
const imgClass = 'img.x5yr21d.xu96u03.x10l6tqk.x13vifvy.x87ps6o.xh8yej3';
const descClass = 'h1._aacl._aaco._aacu._aacx._aad7._aade';
const image = await page.waitForSelector(imgClass);
const imageUrl = await image.getAttribute('src')
const desc = await page.waitForSelector(descClass);
const descText = await desc.innerText()
await browser.close();
return {
statusCode: 200,
body: JSON.stringify({imageUrl, descText}),
};
} catch (error) {
console.error(error);
return {
statusCode: 400,
body: JSON.stringify({error: error.message}),
};
}
};
=
Packages are at:
"dependencies": {
"playwright-aws-lambda": "^0.10.0",
"playwright-core": "^1.32.0"
}
Aws lambda
Node v16.x
Memory 1600
x86_64
Can you provide an example to how deploy this package as lambda layer? For example, in chrome-aws-lambda use this command to build a .zip file to upload to AWS Lambda Layer
git clone --depth=1 https://github.com/alixaxel/chrome-aws-lambda.git && \
cd chrome-aws-lambda && \
make chrome_aws_lambda.zip
EDIT:
I found a solution: add Makefile to this project for use the same command as chrome-aws-lambda. Also, I made a pull request with this change. Tell me if you need more info.
Hello, it seems that current version of chromium.br file doesn't support node 16.x version. (eg. String.prototype.replaceAll is not supported in this version)
is there any official support for updating version of chromium?
Hi! Thank you for all the hard work in this library! ๐
I discovered that this library is using exactly the same paths for chrome binaries as chrome-aws-lambda ( https://github.com/alixaxel/chrome-aws-lambda/blob/master/source/index.js#L166 ). This makes using both libraries in the same lambda a bit cumbersome. I would like to suggest putting the inflated binaries in a directory, for example /tmp/playwright-aws-lambda/chromium
, or adding a prefix to the names.
I would be glad to help with a PR to tackle this issue ๐ .
A bonus thing that is present in chrome-aws-lambda
, and missing in this library is the ability to await on executablePath
(currently I have to inflate the files manually if I don't want to launch the browser).
const [b1,b2] = await Promise.all([playwright.launchChromium({
headless: true,
}), playwright.launchChromium({
headless: true,
})])
browserType.launch: spawn ETXTBSY\nCall log:\n - <launching> /tmp/chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --autoplay-policy=user-gesture-required --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-domain-reliability --disable-extensions --disable-features=AudioServiceOutOfProcess --disable-hang-monitor --disable-ipc-flooding-protection --disable-notifications --disable-offer-store-unmasked-wallet-cards --disable-popup-blocking --disable-print-preview --disable-prompt-on-repost --disable-renderer-backgrounding --disable-setuid-sandbox --disable-speech-api --disable-sync --disk-cache-size=33554432 --hide-scrollbars --ignore-gpu-blacklist --metrics-recording-only --mute-audio --no-default-browser-check --no-first-run --no-pings --no-sandbox --no-zygote --password-store=basic --use-gl=swiftshader --use-mock-keychain --single-process --user-data-dir=/tmp/playwright_chromiumdev_profile-i3Vycb --remote-debugging-pipe --no-startup-window\n",
"trace": [
"browserType.launch: spawn ETXTBSY",
"Call log:",
" - <launching> /tmp/chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --autoplay-policy=user-gesture-required --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-domain-reliability --disable-extensions --disable-features=AudioServiceOutOfProcess --disable-hang-monitor --disable-ipc-flooding-protection --disable-notifications --disable-offer-store-unmasked-wallet-cards --disable-popup-blocking --disable-print-preview --disable-prompt-on-repost --disable-renderer-backgrounding --disable-setuid-sandbox --disable-speech-api --disable-sync --disk-cache-size=33554432 --hide-scrollbars --ignore-gpu-blacklist --metrics-recording-only --mute-audio --no-default-browser-check --no-first-run --no-pings --no-sandbox --no-zygote --password-store=basic --use-gl=swiftshader --use-mock-keychain --single-process --user-data-dir=/tmp/playwright_chromiumdev_profile-i3Vycb --remote-debugging-pipe --no-startup-window",
"",
" at Object.launchChromium (/opt/nodejs/node_modules/playwright-aws-lambda/dist/src/chromium.js:97:47)",
" at async Downloader.getBrowserContext (/var/task/src/app.js:204:19)",
" at async Downloader.downloadPage (/var/task/src/app.js:47:25)",
" at async Downloader.downloadPageByBatch (/var/task/src/app.js:6:15)",
" at async Runtime.handler (/var/task/src/app.js:318:13)"
]
}
Hi, i'm trying to use tiktok-api (https://github.com/davidteather/TikTok-Api) in a lambda but this require playwright. Can i use playwright-aws-lambda with tiktok-api?
Thank you!
I got
[pid=24][err] /tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
with runtime: Node.js 16.x
and this - sample code:
const playwright = require('playwright-aws-lambda');
exports.handler = async(event, context)=>{
let browser = null;
try{
browser = await playwright.launchChromium();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(event.url || 'https://example.com');
console.log('Page title: ', await page.title());
}catch(error){
throw error;
}finally{
if(browser){
await browser.close();
}
}
};
Hello, I'm running the example code using Netlify functions and receiving the following error -
{ "errorType": "TypeError", "errorMessage": "Cannot read property 'launch' of undefined", "trace": [ "TypeError: Cannot read property 'launch' of undefined", " at Object.launchChromium (/var/task/src/node_modules/playwright-aws-lambda/dist/src/chromium.js:90:47)", " at processTicksAndRejections (internal/process/task_queues.js:97:5)", " at async Runtime.exports.handler (/var/task/src/makescreengrab.js:8:25)" ] }
There are transitive dependencies of lambdafs
which depend on vulnerable versions of minimist
and bl
. It's not clear to me how this vulnerability might affect playwright-aws-lambda
in practice, but it does create scary-looking noise upon npm install
.
An example of npm install playwright-aws-lambda
output on a fresh project:
up to date, audited 20 packages in 451ms
3 vulnerabilities (2 moderate, 1 critical)
To address all issues, run:
npm audit fix
Run `npm audit` for details.
And the npm audit
report:
# npm audit report
bl 3.0.0
Severity: moderate
Remote Memory Exposure in bl - https://github.com/advisories/GHSA-pp7h-53gx-mx7r
fix available via `npm audit fix`
node_modules/lambdafs/node_modules/bl
minimist <=1.2.5
Severity: critical
Prototype Pollution in minimist - https://github.com/advisories/GHSA-xvch-5gv4-984h
Prototype Pollution in minimist - https://github.com/advisories/GHSA-vh95-rmgr-6w4m
fix available via `npm audit fix`
node_modules/lambdafs/node_modules/minimist
mkdirp 0.4.1 - 0.5.1
Depends on vulnerable versions of minimist
node_modules/lambdafs/node_modules/mkdirp
3 vulnerabilities (2 moderate, 1 critical)
To address all issues, run:
npm audit fix
Unfortunately, npm audit fix
does nothing to resolve the issue. This appears to be a known issue in NPM itself.
There's seemingly a bazillion different places where this specific issue could be resolved upstream, but getting support for packages that appear to be stale is a challenge. Perhaps a solution can be implemented directly by playwright-aws-lambda
?
Lambda 1:
playwright-aws-lambda v0.9.0
Node 16
Lambda 2:
playwright-aws-lambda v0.10.0
Node 18
AWS Lambda
CI/CD Gitlab
When trying to go to a URL with page.goto(), getting continuous error - 'Error: page.goto: Target page, context or browser has been closed'.
At handler level the error says - "TypeError: Cannot read properties of undefined (reading 'close')\n at d. (/var/task/src/handler.js:1:17387)\n at Generator.next ()\n at a (/var/task/src/handler.js:1:15631)"
The above error in occurring in lambdas which got built by Gitlab pipeline on/after April 18. The same code is still working fine for the lambdas that were build and deployed before April 18.
The deployment packages for old and new deployments are totally same - node module versions and configs.
Any recent updates somewhere would have affected this? TIA.
Hi Team,
when can we expect update playwright-aws-lambda on version playwright v1.2.0?
tnx a lot!
After upgrade Playwright to 1.9.2 this error is happening on Vercel functions.
2021-03-16T19:57:07.806Z undefined ERROR Error: ENOENT: no such file or directory, open '/var/task/node_modules/playwright-core/browsers.json'
at Object.openSync (fs.js:462:3)
at Object.readFileSync (fs.js:364:35)
at new Registry (/var/task/node_modules/playwright-core/lib/utils/registry.js:213:54)
at new Playwright (/var/task/node_modules/playwright-core/lib/server/playwright.js:46:23)
at Object.createPlaywright (/var/task/node_modules/playwright-core/lib/server/playwright.js:59:12)
at setupInProcess (/var/task/node_modules/playwright-core/lib/inprocess.js:24:37)
at Object.<anonymous> (/var/task/node_modules/playwright-core/lib/inprocess.js:42:18)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/var/task/node_modules/playwright-core/browsers.json'
}
RequestId: fafc5e6c-b338-4ba2-90b0-a019fd78923b Error: Runtime exited with error: exit status 1
Runtime.ExitError
We should add a GitHub action for auto-publishing to npm when a new version + git tag is added and the branch is master
.
Using versions;
"playwright-aws-lambda": "^0.6.0",
"playwright-core": "^1.7.1",
Trying to run pl-aws-chrome with a specific user profile fails, 'launchPersistentContext' is not defined for pl-aws-chrome, and passing as args fail as well. Not sure how to solve this issue, could use some help
running
const playwrightAWS = require('playwright-aws-lambda');
chromium = await playwrightAWS.launchChromium({headless: true, userDataDir: './user_profiles/'});
will result with:
Uncaught:
Error: browserType.launch: userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistentContext` instead
at Object.assert (SOME_PATH/node_modules/playwright-core/lib/utils/utils.js:80:15)
at SOME_PATH/node_modules/playwright-core/lib/client/browserType.js:56:21
at BrowserType._wrapApiCall (SOME_PATH/node_modules/playwright-core/lib/client/channelOwner.js:77:34)
at BrowserType.launch (SOME_PATH/node_modules/playwright-core/lib/client/browserType.js:55:21)
at Object.launchChromium (SOME_PATH/node_modules/playwright-aws-lambda/dist/src/chromium.js:97:47)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async repl:1:35
passing directory with profile flags in args:
chromium = await playwrightAWS.launchChromium({headless: true, args: ['--profile-directory=./user_profiles/', '--user-data-dir=./user_profiles/']});
Uncaught:
browserType.launch: Pass userDataDir parameter instead of specifying --user-data-dir argumentError
Has anyone successfully got video recording to work on lambda + playwright?
Working fine locally, but after deploying to lambda:
browserContext.newPage: Executable doesn't exist at /home/sbx_user1051/.cache/ms-playwright/ffmpeg-1007/ffmpeg-linux
Attempting to install ffmpeg via a lambda layer results in a package size that's too big for lambda.
Attempting to install ffmpeg and set the path via:
const pathToFfmpeg = require('ffmpeg-static');
const ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath(pathToFfmpeg);
Results in the same error as above.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.