Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Fix request interception for POST requests

Ondra Urban0c33b195bca1
diff --git a/src/puppeteer_request_interception.js b/src/puppeteer_request_interception.js
index ccf6ada19..ef8e50808 100644
--- a/src/puppeteer_request_interception.js
+++ b/src/puppeteer_request_interception.js
@@ -13,6 +13,10 @@ const pageInterceptRequestMasterHandlerMap = new WeakMap(); // Maps page to mast
* @ignore
*/
const handleRequest = (request, interceptRequestHandlers) => {
+ // If there are no intercept handlers, it means that request interception is not enabled (anymore)
+ // and therefore .abort() .respond() and .continue() would throw and crash the process.
+ if (!interceptRequestHandlers.length) return;
+
let wasAborted = false;
let wasResponded = false;
let wasContinued = false;