Skip to content

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

Closed

Description

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

Activity

  1. changed the title [-][Bug]:[/-] [+][Bug]: Error when unrouting with wait behavior in v1.53[/+] on Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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