Skip to content

[Bug]: Error when unrouting with wait behavior in v1.53 #36585

@RylanBueckert-Broadsign

Description

@RylanBueckert-Broadsign

Version

1.53.2

Steps to reproduce

To Reproduce:

  1. Create a new project with npm init playwright@latest new-project
  2. Create a test with the following properties:
    • Mocks an API with page.route to first fetch, then fufill the route with the response
    • Page calls that API on load or on some action
    • call page.unrouteAll with behaavior 'wait'
    • Example:
import { test } from '@playwright/test';

test('route bug example', async ({ page }) => {
  await page.route('https://jsonplaceholder.typicode.com/todos/1', async (route) => {
    const response = await route.fetch();
    
    await route.fulfill({ response });
  })
  
  await page.goto('https://jsonplaceholder.typicode.com/');
  
  await page.getByRole('button', { name: 'Run Script' }).click();
  
  await page.unrouteAll({ behavior: 'wait' });
});
  1. Run tests playwright test
  2. Some browsers have an error: Error: route.fulfill: Route is already handled! (chromium, webkit)

Expected behavior

I expect that await page.unrouteAll({ behavior: 'wait' }) would wait for the mocked route to finish before unmocking.

Actual behavior

Route appears to be unmocked while still in progress resulting in an error.

Additional context

This error only started happening in 1.53. If @playwright/test is downgraded to 1.52.0, the error does not occur.

Environment

System:
    OS: Windows 11 10.0.26100
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 8.62 GB / 31.73 GB
  Binaries:
    Node: 22.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.4.2 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    VSCode: 1.98.2 - C:\Users\rylanb\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
  Languages:
    Bash: 5.2.37 - C:\Program Files\Git\usr\bin\bash.EXE
  npmPackages:
    @playwright/test: ^1.53.2 => 1.53.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions