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.

[BUG] Protocol error (Network.getResponseBody): Request content was evicted from inspector cache

See original GitHub issue

I am trying to read a large JSON file around 24.9 MB using playwright. When I am making the request and trying to read the body using the playwright.BrowserContext response event but I am getting this error response.json: Protocol error (Network.getResponseBody): Request content was evicted from inspector cache at BrowserContext.<anonymous>

This issue is raised and it’s closed. I have tried to execute same code snippet but it’s not working in playwright.

  • Playwright Version: 1.20.1
  • Operating System: macOS Monterey v12.3 ( M1 )
  • Node.js version: v17.7.0
  • Browser: Chromium

What steps will reproduce the problem?

import playwright from 'playwright';

const getBrowser = async () => {
  const launchOptions = {
    devtools: false,
    headless: false,
    ignoreDefaultArgs: ['--disable-extensions', '--enable-automation'],
    args: [`--start-maximized`],
  };
  const browser = await playwright['chromium'].launch(launchOptions);
  const context = await browser.newContext({ viewport: null });
  return {
    context: context,
    newPage: () => context.newPage(),
    close: () => browser.close(),
  };
};

(async () => {
  const { newPage, context } = await getBrowser();
  const page = await newPage();
  const client = await page.context().newCDPSession(page);
  await client.send('Page.setLifecycleEventsEnabled', { enabled: true });
  await client.send('Network.enable', {
    maxResourceBufferSize: 1024 * 1204 * 100,
    maxTotalBufferSize: 1024 * 1204 * 200,
  });

  context.on('response', async (response) => {
    try {
      const url = response.url();
      if (url.includes('json')) {
        await response.json();
        // getting error in console:
      }
    } catch (e) {
      console.log(e);
    }
  });

  await page.goto(`https://raw.githubusercontent.com/json-iterator/test-data/master/large-file.json`, {
    waitUntil: 'networkidle',
  });
})();

What is the expected result? The expected result it the response of JSON

What happens instead? It throws following error

Protocol error (Network.getResponseBody): Request content was evicted from inspector cache
   at BrowserContext.<anonymous>

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
dwtcommented, Aug 26, 2022

Same problem here…

3reactions
mxschmittcommented, Apr 11, 2022

We’ll p3 it for now an collecting feedback to see if other folks run into it since loading 10mb+ bodies is not very common.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Protocol error (Network.getResponseBody): Request content ...
Error: Protocol error (Network.getResponseBody): Request content was evicted from inspector cache from getting response body from large XML page (around ...
Read more >
Evaluation failed: Object` and `Error: Protocol error (Network ...
getResponseBody ): Request content was evicted from inspector cache occurs. Any suggestions on how I could -. Solve the page.evaluate issue.
Read more >
771825 - DevTools: Network.getResponseBody should return ...
The protocol's method Network.getResponseBody returns a string that is decoded according to the Content-Type response header.
Read more >
How to Fix Chrome's Failed to Load Response Data Error
Chrome failed to load response data request content was evicted from inspector cache; Chrome failed to load response data after redirect. How ...
Read more >
Issue 453078 in chromium: "Failed to load response data"
1. Use the Developer Tools, Network tab · 2. click on a request · 3. click the "Response" tab
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