Rayrun
← Back to Discord Forum

route.fulfill crashes/finished the execution on large response bodies ~85MB JSON

ciprian_39312posted in #help-playwright
Open in Discord
ciprian_39312
await page.route(
  `**/a_url*`,
  async (route) => {
    const response = await route.fetch({ timeout: 0 });
    await route.fulfill({ response });
  },
  { times: 1 }
);

I have this setup and I'm getting the following behaviour. I'm running my tests in Chromium.

  1. I intercept a request and fetch the response myself that happens to be very large.
  2. I fulfill it without modifying the original.
  3. As soon as or right before it is fulfilled the whole test crashes, or more precisely the page closes.
Error: page.waitForResponse: Page closed

      413 |     );
      414 |
    > 415 |     const rPromise = page.waitForResponse((response) => response.url().includes("/another_url"));
          |                           ^
      416 |     await page.goto(`my.website.com`);
      417 |     await rPromise;
      418 |   });

It does not happen if I just continue, for example. My best guess so far is that I am hitting some sort of protocol/DevTools limitation. I tried investigating a little bit on my own, but could not find anything conclusive or a workaround.

Does anybody have an idea what is happening? I'd be happy to provide some additional logs, let me know, the options I have tried did not seem to be too useful in figuring out what the issue is.

This thread is trying to answer question "Why does the test crash when trying to fulfill a large response body using the route.fulfill method in Chromium and how can it be resolved?"

1 reply
ciprian_39312

The whole setup:

test("repro", async ({ page }) => {
  await page.route(
    `**/another_url*`,
    async (route) => {
      const response = await route.fetch({ timeout: 0 });
      await route.fulfill({ response });
    },
    { times: 1 }
  );
  await page.route(
    `**/a_url*`, // this is the route that fulfils first and is large
    async (route) => {
      const response = await route.fetch({ timeout: 0 });
      await route.fulfill({ response });
    },
    { times: 1 }
  );
  const rPromise = page.waitForResponse((response) => response.url().includes("/another_url"));
  await page.goto("my.website.com");
  await rPromise;
});
TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].