microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
67.05k stars 3.68k forks source link

[Bug vs Undocumented Breaking Change?]: v1.41.x Error: Protocol error (Fetch.fulfillRequest): Invalid http status code or phrase #29311

Closed shamoon closed 9 months ago

shamoon commented 9 months ago

Version

v1.41.0-v1.41.2

Steps to reproduce

Hi there, first of all thanks to you all for the amazing tool.

Im a little unclear if the following was either an unintended breaking change or if Im missing something but a dependabot update from 1.40.1 --> 1.41.2 suddenly caused test failures on our project, see https://github.com/paperless-ngx/paperless-ngx/actions/runs/7748673176/job/21131798824?pr=5634 which fails with Error: Protocol error (Fetch.fulfillRequest): Invalid http status code or phrase

As best I can tell this comes down to us using .HAR files that have some requests that I think get canceled in the course of running tests (e.g. navigating around the app quickly) and the status is recorded as -1 and statusText: "". This was of course working until the update, specifically I localized it to 1.41.0 but as above its still the case in 1.41.2

I tried re-recoding the HAR files but get the same thing. I'm not totally clear which part here is incorrect (if status = -1 is invalid should the HAR recording ever generate that?). I can of course update the .HAR to return 200 or whatever but the question is just whether this is a bug vs. expected now (and if so should probably be noted somewhere, sorry if it is and I missed it).

Again, see the CI run above but an example is a simple test like:

test('dashboard total documents link', async ({ page }) => {
  await page.routeFromHAR(REQUESTS_HAR2, { notFound: 'fallback' })
  await page.goto('/dashboard')
  await page.getByRole('link').filter({ hasText: 'Total documents' }).click()
  await expect(page).toHaveURL(/documents/)
  await expect(page.locator('pngx-document-list')).toHaveText(/61 documents/)
  await page.getByRole('button', { name: 'Reset filters' })
})

And a .HAR file with a bunch of requests but at least one like:

      {
        "startedDateTime": "2024-02-02T00:04:03.725Z",
        "time": -1,
        "request": {
          "method": "GET",
          "url": "http://localhost:8000/api/documents/307/thumb/",
          "httpVersion": "HTTP/1.1",
          "cookies": [],
          "headers": [
            { "name": "Accept-Language", "value": "en-US" },
            { "name": "Referer", "value": "http://localhost:4200/" },
            { "name": "User-Agent", "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.57 Safari/537.36" }
          ],
          "queryString": [],
          "headersSize": -1,
          "bodySize": -1
        },
        "response": {
          "status": -1,
          "statusText": "",
          "httpVersion": "HTTP/1.1",
          "cookies": [],
          "headers": [],
          "content": {
            "size": -1,
            "mimeType": "x-unknown"
          },
          "headersSize": -1,
          "bodySize": -1,
          "redirectURL": ""
        },
        "cache": {},
        "timings": { "send": -1, "wait": -1, "receive": -1 }
      },

Expected behavior

Existing tests that use a .HAR with status: -1/statusText: "" dont fail

Actual behavior

Previously-working tests that use a .HAR with status: -1/statusText: "" now fail with Error: Protocol error (Fetch.fulfillRequest): Invalid http status code or phrase

Additional context

Thank you for the awesome project!

Environment

This is local, note link above from CI

  System:
    OS: macOS 14.1.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 184.38 MB / 16.00 GB
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    pnpm: 8.12.1 - ~/.nvm/versions/node/v20.10.0/bin/pnpm
    bun: 1.0.1 - ~/.bun/bin/bun
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.41.0 => 1.41.0
jamiemac87 commented 9 months ago

Having the same issue

shamoon commented 9 months ago

Thank you!

kurkle commented 7 months ago

Same (undocumented breaking change?) also happens with status 419 when upgrading from 1.41.0 -> 1.42.1

corradopetrelli commented 7 months ago

Same issue with 1.42.1

ani-im commented 6 months ago

The same issue with 440 status code when using 1.42.1