puppeteer-cluster icon indicating copy to clipboard operation
puppeteer-cluster copied to clipboard

How to do one-time setup ?

Open asafyish opened this issue 4 years ago • 1 comments

Hi,

I want to prevent some files from loading, and for that, I need to intercept requests for each page object, this is done by

page.on('request', (request) => {
// block
});

The problem is, how can I ensure this setup is run just once ? otherwise I am risking that I will add multiple event handlers that do the exact same thing over and over again. For now, I am adding a flag to the page object to tell if I already attached an the request handler (but don't feel like the right way);

asafyish avatar Jun 06 '20 07:06 asafyish

@asafyish did you ever figure this out?

DawidOskwarek avatar Jan 17 '23 14:01 DawidOskwarek