closes #148
This commit is contained in:
parent
bb952358a2
commit
94b8687686
11
README.md
11
README.md
|
|
@ -204,6 +204,17 @@ From what I can tell, `headless_shell` does not seem to include support for the
|
|||
|
||||
Try marking this package as an external. Ref: https://webpack.js.org/configuration/externals/
|
||||
|
||||
### I'm experiencing timeouts or failures closing Chromium
|
||||
|
||||
This is a common issue. Chromium sometimes opens up more pages than you ask for. You can try the following
|
||||
|
||||
```typescript
|
||||
for (const page of await browser.pages()) {
|
||||
await page.close();
|
||||
}
|
||||
await browser.close();
|
||||
```
|
||||
|
||||
## Fonts
|
||||
|
||||
The Amazon Linux 2 AWS Lambda runtime is not provisioned with any font faces.
|
||||
|
|
|
|||
|
|
@ -18,15 +18,8 @@ exports.handler = async (event, context) => {
|
|||
|
||||
console.log("Chromium version", await browser.version());
|
||||
|
||||
const contexts = [browser.defaultBrowserContext()];
|
||||
|
||||
while (contexts.length < event.length) {
|
||||
contexts.push(await browser.createBrowserContext());
|
||||
}
|
||||
|
||||
for (let context of contexts) {
|
||||
const job = event.shift();
|
||||
const page = await context.newPage();
|
||||
for (let job of event) {
|
||||
const page = await browser.newPage();
|
||||
|
||||
if (job.hasOwnProperty("url") === true) {
|
||||
await page.goto(job.url, { waitUntil: ["domcontentloaded", "load"] });
|
||||
|
|
@ -68,6 +61,9 @@ exports.handler = async (event, context) => {
|
|||
throw error.message;
|
||||
} finally {
|
||||
if (browser !== null) {
|
||||
for (const page of await browser.pages()) {
|
||||
await page.close();
|
||||
}
|
||||
await browser.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue