Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Handling: Response body is unavailable for redirect responses #29441

Closed
jaktestowac opened this issue Feb 9, 2024 · 2 comments · Fixed by #29481
Closed

[Bug]: Handling: Response body is unavailable for redirect responses #29441

jaktestowac opened this issue Feb 9, 2024 · 2 comments · Fixed by #29481
Assignees
Labels

Comments

@jaktestowac
Copy link
Contributor

Version

1.42.0-alpha-2024-02-09

Steps to reproduce

Run test with default project:

import { test, expect } from '@playwright/test';

const pageUrl = 'https://automationintesting.online/';

test('should return 304', async ({ page }) => {
  const response200Promise = page.waitForResponse((response) => {
    console.log(response.status(), response.url());
    return response.url() === pageUrl;
  });

  await page.goto(pageUrl);
  expect((await response200Promise).status()).toBe(200);

  const response304Promise = page.waitForResponse((response) => {
    console.log(response.status(), response.url());
    return response.url() === pageUrl;
  });

  await page.reload();
  const response304 = await response304Promise;

  const responseText = await response304.text();
  expect(responseText).toContain('Restful-booker-platform demo');

  expect(response304.status()).toBe(304);
});

Expected behavior

Request inspected in browser return cached content - so should we also get this content here?

Actual behavior

304 request not contain body

Additional context

Connected issue: #28779
This behavior introduces a breaking change from previous behavior.

Before the change, 304 responses were treated as 200, which allowed for the body to be inspected without any issues.
(just run provided test on Playwright 1.41)

Now some of my tests failing (on 1.42.0-alpha) due to mentioned change.
What is proposed migration steps to handle this problem?

Environment

System:
    OS: Windows 11
    CPU: Intel(R) Core(TM) i7
    Memory: 45.09 GB / 63.71 GB
  Binaries:
    Node: 20.11.0 
    npm: 10.4.0
  IDEs:
    VSCode: 1.86.0
  npmPackages:
    @playwright/test: ^1.42.0-alpha-2024-02-09 => 1.42.0-alpha-2024-02-09
@yury-s
Copy link
Member

yury-s commented Feb 12, 2024

According to the MDN docs "The response must not contain a body", so it is working as intended.

yury-s added a commit to yury-s/playwright that referenced this issue Feb 13, 2024
@yury-s
Copy link
Member

yury-s commented Feb 13, 2024

We discussed this with the team and decided to revert the original change as it is going to break those who previously relied on getting response body. @jaktestowac thanks for helping us prevent the breakage before the release. I'll add a note to the original bug about what the proper fix could be from our stand point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants