microsoft / microsoft/playwright
[BUG] Protocol error (Network.getResponseBody): Request content was evicted from inspector cache
- Dominant language
- TypeScript
- Stars
- 96.3k
- Forks
- 6.5k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 180
Description
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.`
This [issue](https://github.com/puppeteer/puppeteer/issues/1599) is raised and it's closed. I have tried to execute same [code](https://github.com/puppeteer/puppeteer/issues/1599#issuecomment-355473214) 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?**
```javascript
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.
```
Contributor guide
Research direction
Start with the supplied Playwright reproduction, focusing on the BrowserContext response event, response.json(), and the CDP Network.getResponseBody call. Verify behavior with the linked large JSON resource; done means reliably reading the complete response without the inspector-cache eviction error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100