How to abort request if page is redirecting?

I've tried multiple different approaches but to no avail:

page.on('response', async (response) => {
    if (Number(response.status()) === 301 || Number(response.status()) === 302) {
      // crawlerContext.request.cancel(); // not working
      // response.cancel() // not working
      
      // crawlerContext.request.abort(); // not working
      // response.abort() // not working
    }
}
Was this page helpful?