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

[Question] Using firefox as browser on test throws: Response body is unavailable for redirect responses #3987

Closed
maurusrv opened this issue Sep 26, 2020 · 2 comments

Comments

@maurusrv
Copy link

I'm new in using jest and playwright but using it is really a breeze. I don't have anymore detailed explanation but what i wrote in the title. What does this message mean?

Here's what i encounter:

    Response body is unavailable for redirect responses

      at node_modules/playwright/lib/server/network.js:210:27
      at ResponseDispatcher.body (node_modules/playwright/lib/dispatchers/networkDispatchers.js:62:27)
      at DispatcherConnection.dispatch (node_modules/playwright/lib/dispatchers/dispatcher.js:137:28)

This only throws on my test cases when the browser i use is firefox. may test passes on both chrome and webkit.

Thanks in advance!

@dgozman
Copy link
Contributor

dgozman commented Sep 30, 2020

Unfortunately, response body is not always available. For example, it is not available for redirect responses, when server responds, for example, with 302 server redirect. According to our tests, this should be the case for all browsers. My guess would be that server sends different response for Firefox in your particular case.

I'd suggest to catch the error when accessing response.body:

page.on('response', async response => {
  const body = await response.body().catch(e => null);
  if (!body)
    console.log('Failed to fetch response body');
  else
    doSomethingWithResponseBody(body);
});

Does this answer your question?

@dgozman dgozman closed this as completed Sep 30, 2020
@maurusrv
Copy link
Author

maurusrv commented Oct 5, 2020

I found out that in my case, it was 304 responses that i keep getting, and i think it's because my tests sometimes involves a lot of calling the same endpoint.

But now i wonder why this only happens on Firefox though. some nuance among the different browsers huh.

Anyway, thanks for the insight @dgozman!

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

No branches or pull requests

2 participants