Rename variables for clarity and update browser pool management

This commit is contained in:
ImBenji
2025-12-31 19:13:43 +00:00
parent 737d8d3ad5
commit 2245b31af6

View File

@@ -58,17 +58,21 @@ async function renderHtml(html, waitTime = 1000) {
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
await new Promise(resolve => setTimeout(resolve, waitTime));
const screenshot = await page.screenshot({
type: 'png',
fullPage: false
fullPage: false,
encoding: 'binary'
});
return screenshot;
return Buffer.from(screenshot);
} finally {
if (page) await page.close();
releaseBrowser(browser);