Skip to content

[Bug]: 204 response are considered failed #32752

Open
@Mattwmaster58

Description

@Mattwmaster58

Version

1.47

Steps to reproduce

server for serving HTML (doesn't matter how, just an example):

from flask import Flask
app = Flask(__name__)

@app.route('/')
def index():
    return '''
<!DOCTYPE html>
<html>
<script>
  fetch('https://httpbin.org/status/204');
</script>
</html>
    '''

if __name__ == '__main__':
    app.run(debug=True, port=5001)

repro:

import asyncio

from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        def catch_request_failure(s):
            print(s.url, " failed ", s.failure)
        page.on("requestfailed", catch_request_failure)
        await page.goto("http://127.0.0.1:5001", wait_until="networkidle")


asyncio.run(main())

Expected behavior

No output from the script. There are no requests that have failed.

Actual behavior

https://httpbin.org/status/204  failed  net::ERR_ABORTED

This isn't true, the request succeeded. If you run with launch(devtools=True) then you can see the very request in the devtools and that it did succeed.

Additional context

Similar to #26897, #31570

However, this time I think it's different as instead of talking about a Page.goto call, it's a request initiated by the page. There was justification in #31570 that a failure of navigation could be technically correct as no navigation takes place, but for a request initiated by a page, I do not think that a requestfailed event is correct.

In my use case, I monitor the requests that a site makes on load for privacy assessment. It's important to know whether a request was actually made or whether it happened to failed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions