question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Protocol error (Network.getResponseBody): No resource with given identifier found

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.20.0
  • Platform / OS version: Arch Linux
  • URLs (if applicable):
  • Node.js version: 10.16.1

What steps will reproduce the problem?

I’m trying to get content from an iframe by navigating to the URL of the iframe. I’ve tried without a Chrome Devtools Protocol session: const client = await page.target().createCDPSession(); and it works but it breaks with the following error otherwise.

client.on("Network.loadingFinished", async ({ requestId }) => {
counter++;
const params = await client.send("Network.getResponseBody", { requestId });
counter--;
const { body, base64Encoded } = params;
events.push({
	method: "Network.getResponseBody",
	params: {
	requestId,
	body,
	base64Encoded
	}
});
if (counter === 0) {
	finish();
}
});
if (iframesList.length > 0) {
for (let frameIndex = 0; frameIndex < iframesList.length; frameIndex++) {
	const iframe = iframesList[frameIndex];
	console.log("frameIndex: ", frameIndex);
	const src = await iframe.evaluate(() => {
	const inputElementArr = [...document.querySelectorAll("input")];
	window.cl("inputElementArr.length: ", inputElementArr.length);
	return document.querySelector("iframe").getAttribute("src");
	});
	console.log(src);
	console.log(iframe.url());
	await page.goto(src);
	await navigationPromise;
}
}

(Code snippet taken from here: https://github.com/cyrus-and/chrome-har-capturer/issues/75#issuecomment-531690406 ) What is the expected result? Navigate to the URL of the iframe and get content without an error.

What happens instead?

(node:1203418) UnhandledPromiseRejectionWarning: Error: Protocol error (Network.getResponseBody): No resource with given identifier found
    at Promise (/home/user/node_modules/puppeteer/lib/Connection.js:183:56)
    at new Promise (<anonymous>)
    at CDPSession.send (/home/user/node_modules/puppeteer/lib/Connection.js:182:12)
    at CDPSession.client.on (/home/user/chc03.js:85:33)
    at CDPSession.emit (events.js:203:15)
    at CDPSession._onMessage (/home/user/node_modules/puppeteer/lib/Connection.js:200:12)
    at Connection._onMessage (/home/user/node_modules/puppeteer/lib/Connection.js:112:17)
    at WebSocketTransport._ws.addEventListener.event (/home/user/node_modules/puppeteer/lib/WebSocketTransport.js:44:24)
    at WebSocket.onMessage (/home/user/node_modules/puppeteer/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:198:13)
(node:1203418) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 13)
(node:1203418) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:1203418) UnhandledPromiseRejectionWarning: Error: Protocol error (Network.getResponseBody): No resource with given identifier found
    at Promise (/home/user/node_modules/puppeteer/lib/Connection.js:183:56)
    at new Promise (<anonymous>)
    at CDPSession.send (/home/user/node_modules/puppeteer/lib/Connection.js:182:12)
    at CDPSession.client.on (/home/user/chc03.js:85:33)
    at CDPSession.emit (events.js:203:15)
    at CDPSession._onMessage (/home/user/node_modules/puppeteer/lib/Connection.js:200:12)
    at Connection._onMessage (/home/user/node_modules/puppeteer/lib/Connection.js:112:17)
    at WebSocketTransport._ws.addEventListener.event (/home/user/node_modules/puppeteer/lib/WebSocketTransport.js:44:24)
    at WebSocket.onMessage (/home/user/node_modules/puppeteer/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:198:13)
(node:1203418) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 14)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

9reactions
alberthuang24commented, Jul 9, 2020

I solved it this way for your reference

    let paused = false;
    let pausedRequests = [];
    const nextRequest = () => {
        // continue the next request or "unpause"
        if (pausedRequests.length === 0) {
            paused = false;
        } else {
            // continue first request in "queue"
            // calls the request.continue function
            (pausedRequests.shift())();
        }
    };

    await page.setRequestInterception(true);
    page.on('request', request => {
        if (paused) {
            pausedRequests.push(() => request.continue());
            return;
        } 
        paused = true;
        // pause, as we are processing a request now
        request.continue();
    });

    page.on('requestfinished', async request => {
        const response = request.response();
        const headers = response.headers();
        const statusCode = response.status();

        function returnWrapper() {
            nextRequest();
        }

        return returnWrapper();
    });

    page.on('requestfailed', nextRequest);
1reaction
alberthuang24commented, Jul 8, 2020

Hello 👋 @hubitor, When a redirect request is encountered, the browser will interrupt the request of other resources on the current page so this error occurs. You can use setRequestInterception to queue the request

Read more comments on GitHub >

github_iconTop Results From Across the Web

Network.getResponseBody fails for some pages (No resource ...
Network.getResponseBody fails for some pages (No resource with given identifier found undefined) #2258.
Read more >
puppeteer - Error: Protocol error (Network.getResponseBody ...
puppeteer - Error: Protocol error (Network.getResponseBody): No resource with given identifier found ; 'dotenv').config ; const readline = require ...
Read more >
responseReceived but getResponseBody returns error
responseReceived events and follow up with Network.getResponseBody ... returns an error, 'No data found for resource with given identifier'.
Read more >
Chrome Extension: “No resource with given identifier found ...
I'm writing a Chrome Extension that can get HTTP response for a site. I try to use debugger for getting response body: var...
Read more >
third_party/blink/renderer/core/inspector ... - Google Git
static std::unique_ptr<protocol::Network::Headers> BuildObjectForHeaders( ... return Response::Error("No data found for resource with given identifier");.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found