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

[Regression]: "Error: route.fulfill: Protocol error (Fetch.fulfillRequest): Invalid http status code or phrase", with valid 419 code. #30773

Closed
kurkle opened this issue May 14, 2024 · 4 comments · Fixed by #30856
Assignees
Labels

Comments

@kurkle
Copy link

kurkle commented May 14, 2024

Last Good Version

1.40.1

First Bad Version

1.43.1

Steps to reproduce

            // fake expired token response
            await page.route(
                '*/**/api/*',
                (route) => {
                    route.fulfill({
                        status: 419,
                        headers: {
                            'Access-Control-Allow-Origin': '*',
                        },
                        body: 'fake',
                    })
                },
                { times: 1 }
            )

Expected behavior

I expect 419 to be a valid status code (some API's return that and we need to be able to test the case)

Actual behavior

419 is said to be invalid.

Additional context

No response

Environment

System:
    OS: macOS 14.4.1
    Memory: 6.82 GB / 32.00 GB
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
  Languages:
    Bash: 5.2.26 - /opt/homebrew/bin/bash
@mxschmitt
Copy link
Member

In previous versions this wasn't working either, it resulted in a silent catch, when looking at the debug logs:

pw:protocol SEND ► {"id":29,"method":"Fetch.fulfillRequest","params":{"requestId":"interception-job-1.0","responseCode":419,"responseHeaders":[{"name":"content-length","value":"4"}],"body":"ZmFrZQ=="},"sessionId":"24A02879199C3AF17A072D712F8E7922"} +4ms
pw:protocol ◀ RECV {"id":29,"error":{"code":-32602,"message":"Invalid http status code or phrase"},"sessionId":"24A02879199C3AF17A072D712F8E7922"} +0ms

This means, there was no error surfaced to the user and the request also never got fulfilled successfully with 419 status code. As per Wikipedia, 419 is no valid status code.

Since this wasn't working before either, this seems not a regression but a limitation?

@kurkle
Copy link
Author

kurkle commented May 14, 2024

As per the Hypertext Transfer Protocol (HTTP) Status Code Registry, 419 is valid but unassigned.

But you are correct, it did not work before either (and the test in question does not test what it should, duh)

@yury-s
Copy link
Member

yury-s commented May 15, 2024

Is there a reason you want to fulfill with unsupported status code?

@kurkle
Copy link
Author

kurkle commented May 15, 2024

Sure there is, I want to mock actual API reaponse, which has status 419 (for expired token), in this case.

@yury-s yury-s self-assigned this May 16, 2024
@yury-s yury-s added the v1.45 label May 16, 2024
yury-s added a commit to yury-s/playwright that referenced this issue May 16, 2024
@yury-s yury-s closed this as completed in b375f10 May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants