#Finishing requestHandler() request early

1 messages · Page 1 of 1 (latest)

chilly brook
#

Im using Puppeteer requestHandler() and is there a way for me to end the request early instead of waiting for the whole "script" to finish so I could move on to the next URL in the queue?

obtuse steeple
#

Hello @chilly brook, not sure what you mean exactly.
You may end processing the request from inside of the script, just by returning a void.

router.addHandler('START', async ({ $, crawler, request }) => {
    /// ...

    if (nothingToScrape) {
        return; // sucessfully ends this request and continues in another one
    }
    // ...
});
chilly brook
#

Understood, I was doing page.close() and browser.close()

Basically on the page I have a setInterval function that checks for page changes every second, if in 10 seconds the "change" that Im looking for doesn't appear I just want to close the current session and move on to the next request in the queue 🙂