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]: Support http2 for APIRequestContext/Fetch #31730

Open
yosom opened this issue Jul 17, 2024 · 2 comments
Open

[Bug]: Support http2 for APIRequestContext/Fetch #31730

yosom opened this issue Jul 17, 2024 · 2 comments
Assignees

Comments

@yosom
Copy link

yosom commented Jul 17, 2024

Version

1.45.2

Steps to reproduce

I have discovered an issue where the first code, but the second one does not. Please advise on how to proceed as I wish to use route.fulfill().
one:

const { chromium } = require("playwright");

async function main() {
    const browser = await chromium.launch({ headless: false });
    const context = await browser.newContext();

    const page = await context.newPage();


    await page.route('**/*', async (route) => {
        const response = await route.fetch()
        const headers = response.headers()
        const body = await response.body()

        await route.fulfill({
            status: response.status(),
            headers: headers,
            body: body
        });

        return;
    })

    await page.goto('https://www.bitget.com/');
    await new Promise(resolve => setTimeout(resolve, 10000000));

    await browser.close();
}

main();

two

const { chromium } = require("playwright");

async function main() {
    const browser = await chromium.launch({ headless: false });
    const context = await browser.newContext();

    const page = await context.newPage();


    await page.route('**/*', async (route) => {
        const response = await route.fetch()
        const headers = response.headers()
        const body = await response.body()
        route.continue();
        return;
    })

    await page.goto('https://www.bitget.com/');
    await new Promise(resolve => setTimeout(resolve, 10000000));

    await browser.close();
}

main();

Expected behavior

open page

Actual behavior

can`t open

Additional context

No response

Environment

System:
    OS: macOS 14.5
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 58.00 MB / 16.00 GB
  Binaries:
    Node: 20.15.0 - /usr/local/bin/node
    npm: 10.7.0 - /usr/local/bin/npm
  IDEs:
    VSCode: 1.91.1 - /usr/local/bin/code
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    playwright: ^1.45.2 => 1.45.2
@dgozman
Copy link
Contributor

dgozman commented Jul 22, 2024

From the team discussion: we should support http2 in the fetch API, and also include some headers supplied by the network stack in Chromium when doing route.fetch().

@mxschmitt mxschmitt changed the title [Bug]: !!!🪲🪲🪲🪲🪲🪲 [Bug]: Support http2 for APIRequestContext/Fetch Jul 22, 2024
@mxschmitt
Copy link
Member

mxschmitt commented Jul 23, 2024

Investigation notes:

Ideally we migrate to Node.js fetch internally which depends on nodejs/node#43187 and nodejs/undici#2224. This would simplify a lot. Keep supporting https/socks proxies when using a manual http2.connect() requires rewriting the proxy logic, since http2 doesn't support the http.Agent interface.

Marking it as a feature request for now to collect feedback / to see the demand for it.

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

No branches or pull requests

3 participants