Apify Discord Mirror

Updated 5 months ago

Interception error in Puppeteer

At a glance
The community member is getting a TargetCloseError error while using Puppeteer, but they are not doing any request interception in their script. They are simply creating a request and adding it to a crawler using crawler.addRequests. The request is a GET request with a URL and headers. A comment suggests that the issue might be related to missing page.setRequestInterception(true) and recommends checking the Puppeteer documentation.
Useful resources
I'm getting this error in Puppeteer but I'm not doing any interception in my script, I just create a request and add it to the crawler using crawler.addRequests, the request is a get where I just provide url and headers.

Plain Text
DEBUG Error while disabling request interception {"error":{"name":"TargetCloseError","message":"Protocol error (Network.setCacheDisabled): Target closed","stack":"TargetCloseError: Protocol error (Network.setCacheDisabled): Target closed\n at CallbackRegistry.clear (project/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:138:36)\n at CDPSessionImpl._onClosed (project/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:451:25)\n at Connection.onMessage (project/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:248:25)\n at WebSocket.<anonymous> (project/node_modules/puppeteer-core/lib/cjs/puppeteer/common/NodeWebSocketTransport.js:52:32)\n at callListener (project/node_modules/ws/lib/event-target.js:290:14)\n at WebSocket.onMessage (project/node_modules/ws/lib/event-target.js:209:9)\n at WebSocket.emit (node:events:365:28)\n at Receiver.receiverOnMessage (project/node_modules/ws/lib/websocket.js:1184:20)\n at Receiver.emit (node:events:365:28)\n at Receiver.dataMessage (project/node_modules/ws/lib/receiver.js:541:14)"}}
A
1 comment
Check https://pptr.dev/ - if its puppeteer level error SDK just forwarding it to you. Looks like you missed page.setRequestInterception(true) https://pptr.dev/guides/request-interception/
Add a reply
Sign up and join the conversation on Discord