Rename variables for clarity and update browser pool management
This commit is contained in:
@@ -58,17 +58,21 @@ async function renderHtml(html, waitTime = 1000) {
|
|||||||
height: VIEWPORT_HEIGHT
|
height: VIEWPORT_HEIGHT
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.setContent(html, { waitUntil: 'networkidle0' });
|
await page.setContent(html, { waitUntil: ['load', 'domcontentloaded', 'networkidle0'] });
|
||||||
|
|
||||||
|
// wait for body to be ready
|
||||||
|
await page.waitForSelector('body');
|
||||||
|
|
||||||
// wait for any animations or laoding
|
// wait for any animations or laoding
|
||||||
await new Promise(resolve => setTimeout(resolve, waitTime));
|
await new Promise(resolve => setTimeout(resolve, waitTime));
|
||||||
|
|
||||||
const screenshot = await page.screenshot({
|
const screenshot = await page.screenshot({
|
||||||
type: 'png',
|
type: 'png',
|
||||||
fullPage: false
|
fullPage: false,
|
||||||
|
encoding: 'binary'
|
||||||
});
|
});
|
||||||
|
|
||||||
return screenshot;
|
return Buffer.from(screenshot);
|
||||||
} finally {
|
} finally {
|
||||||
if (page) await page.close();
|
if (page) await page.close();
|
||||||
releaseBrowser(browser);
|
releaseBrowser(browser);
|
||||||
|
|||||||
Reference in New Issue
Block a user