Skip to content

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

Open
@yosom

Description

@yosom

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions