Skip to content

delete-data also deletes the persistent profile of any session whose name starts with <name>- #499

Closed
microsoft/playwright
#43928

Description

playwright-cli -s=work delete-data deletes the user data dir of session work-test too.

Session.deleteData() (cli-client/session.ts) removes every entry matching file.startsWith(`ud-${this.name}-`). User data dirs are named ud-${sessionName}-${browserToken}, so ud-work- is a prefix of ud-work-test-chrome.

Steps to reproduce

U=http://127.0.0.1:8765/   # any http origin
for s in work work-test; do
  playwright-cli -s=$s open --persistent $U
  playwright-cli -s=$s localstorage-set k data-of-$s
  playwright-cli -s=$s close
done
ls ~/.cache/ms-playwright/daemon/*/      # ud-work-chrome  ud-work-test-chrome
playwright-cli -s=work delete-data       # Deleted user data for browser 'work'.
ls ~/.cache/ms-playwright/daemon/*/      # both ud-* dirs are gone
playwright-cli -s=work-test open --persistent $U
playwright-cli -s=work-test localstorage-get k

Expected

Only ud-work-* for session work is deleted; work-test still returns k=data-of-work-test (it does when delete-data is not run).

Actual

localStorage key 'k' not found — the profile of work-test (cookies, logins, storage) was deleted.

Suggested fix

Match the exact directory ud-${name}-${browserToken} (or store the user data dir path in the .session file and delete only that).

Environment

  • @playwright/cli 0.1.23 (main @ f50f579), playwright-core 1.65.0-alpha-2026-10-30
  • Node 22.23.4, Linux x64, Chrome for Testing 153

Activity

  1. github-actions commented on Nov 5, 2026

    @github-actions
  2. microsoft-playwright-automation commented on Nov 5, 2026

    @microsoft-playwright-automation
    Contributor

    Hi, I'm the Playwright bot. I reproduced this on Linux.

    Reproduced and fixed in the proposed patch on Linux, using tip-of-tree (1.66.0-next, base edeb0bd05176ff187c372c1e38e5d89a232bd5b3) in Chrome, Chromium, Firefox and WebKit. The directory lookup matches a session-name prefix, so deleting mysession also deletes mysession-test's profile. The fix matches the exact directory name using the session's recorded browser token.

    Draft PR: microsoft/playwright#43928

    Minimal repro and results

    Using a local HTTP page:

    playwright-cli -s=mysession-test open --persistent http://localhost:8919/hello-world
    playwright-cli -s=mysession-test localstorage-set k data-of-mysession-test
    playwright-cli -s=mysession-test close
    playwright-cli -s=mysession open --persistent http://localhost:8919/hello-world
    playwright-cli -s=mysession close
    playwright-cli -s=mysession delete-data
    playwright-cli -s=mysession-test open --persistent http://localhost:8919/hello-world
    playwright-cli -s=mysession-test localstorage-get k

    All four browser projects return localStorage key 'k' not found instead of the stored value. The existing delete-data named session test was extended to check this scenario.

    With the fix, the same test preserves the second session's stored value and confirms that the target profile was deleted. All 232 checks in cli-session, cli-persistent, cli-isolated, cli-storage and cli-json pass across the four browser projects. npm run build and npm run flint pass.

    Triaged on Linux by the Playwright bot - agent run

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

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