#42746·Playwright

[Bug]: `TypeError: Page.__aexit__: : : : : : : function takes exactly 5 arguments (1 given)`

Author: IinksafeCreated Sep 16, 2026Updated Sep 17, 2026

Version

1.62.0

Steps to reproduce

  1. Register a page routing function (using Page.route(url='**', handler=handler))
  2. Fetch the response using response = await route.fetch()
  3. Retrieve the body with await response.text()
  4. An error

will pop-up. (C-level maybe?)

Expected behavior

Retrieve the text successfully (isn't it obvious)

Actual behavior

An exception is thrown (TypeError: : : : : : : function takes exactly 5 arguments (1 given)) — very obscure, doesn't really tell much on its own. For example: what function? when and how did that happen? etc.

Additional context

I'm a real human, in case that had to be said.

My code (run on Python 3.14.2 (tags/v3.14.2:df79316, Dec 5 2025, 17:18:21) [MSC v.1944 64 bit (AMD64)] on win32):

async def route_handler(route: playwright.async_api.Route, request: playwright.async_api.Request):
    response = await route.fetch()
    body = await response.text()  # <== Error occurs here
    body = body.replace("are", "aren't").replace("you", "Link Safe")  # Performs some processing with the text
    await route.fulfill(response=response, body=body)

await page.route('**', route_handler)

Environment

System:
    OS: Windows 11 10.0.26200
    CPU: (16) x64 Intel(R) Core(TM) i5-14400F
    Memory: 2.42 GB / 15.75 GB
  Binaries:
    Node: 24.19.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.17.0 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    VSCode: 1.137.0 - C:\Users\Usuario\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
  npmPackages:
    @playwright/test: ^1.62.1 => 1.62.1