have you figured out how it should be implemented instead?
have you figured out how it should be implemented instead?
browser.close() linethis.browser.isConnected()), and reinstantiate it if notstate.blockConcurrencyWhile() may be the answer, but I haven't tested it yet
We’ve spoken to many customers deploying a Puppeteer service on their own infrastructure, on public cloud containers or functions or using managed services. The common theme that we’ve heard is that these services are costly – costly to maintain and expensive to run.

A browser instance gets killed if it does not get any command for 60 seconds, freeing one instance.
setContent and that html runs some javascript that wants to access a large local json file, can puppeteer somehow access the local filestystem of the worker? Or how would this work?<script> const json = JSON.parse(${rawJson}; ...) and then use page.setContents works, but not sure if this is a performant way to do it.

browser.close()this.browser.isConnected()state.blockConcurrencyWhile()setContent<script> const json = JSON.parse(${rawJson}; ...page.setContents const browser = await pup.launch({
headless: `new`,
defaultViewport: { width: 1920, height: 1080 },
})
const getPageSnapshot = (url, fullPage) => new Promise(async (resolve, reject) => { // this returns a promise resolving to a buffer
const page = await browser.newPage().catch(reject)
await page.goto(url).catch(reject)
resolve(await page.screenshot({
fullPage
}).then(async (r) => { await page.close(); return r }).catch(reject))
}) async handle(
request: Request,
env: any,
context: any,
data: Record<string, any>
) : Promise<Response> {
// some url handling
const browser = await puppeteer.launch(env.MYBROWSER);
const page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 })
await page.goto(url);
const screenshot = (await page.screenshot({
fullPage: false,
})) as Buffer;
await browser.close();
return new Response(screenshot, {
headers: {
'Content-Type': `image/jpeg`,
},
});
} await page.goto(url, {
waitUntil: `load`
});