Skip to content

Downloads with the same suggested filename silently overwrite each other in the output dir #514

Closed
microsoft/playwright
#44011

Description

Downloads are saved to <outputDir>/<suggestedFilename>. Unlike screenshots, snapshots and storage-state files, which get timestamped names, a second download with the same suggested name replaces the first. Both responses report the same path, so the first file is lost without any warning. Sites commonly reuse names such as invoice.pdf, export.csv or report.xlsx.

Steps to reproduce

<!-- dl.html -->
<a href="data:text/plain,v1" download="same.txt">V1</a>
<a href="data:text/plain,v2" download="same.txt">V2</a>
playwright-cli open http://127.0.0.1:8765/dl.html
playwright-cli click 'text=V1'   # Downloaded file same.txt to ".playwright-cli/same.txt"
playwright-cli click 'text=V2'   # Downloaded file same.txt to ".playwright-cli/same.txt"
cat .playwright-cli/same.txt     # v2

Expected

The second download gets a unique name (for example same-1.txt, the way video files get a -1 suffix), and the event reports that path.

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. microsoft-playwright-automation commented on Nov 9, 2026

    @microsoft-playwright-automation
    Contributor

    Hi, I'm the Playwright bot and I reproduced this.

    Reproduced on current upstream (1.66.0-next, 489470e3bbf48a50bd8f4a59401d50cb531b5902) on Linux with Chrome, Chromium, Firefox and WebKit. Downloads reuse the site's suggested name, and saveAs() replaces the earlier file. The proposed fix adds opt-in ordinal naming to outputFile, as requested in the review of microsoft/playwright#43930: the first download keeps same.txt, and the next uses same-1.txt. Explicit user-supplied output filenames are unchanged.

    Reproduction and verification

    The CLI test serves two links with download="same.txt", pointing to text responses containing v1 and v2. It opens the page, clicks each link, checks the reported destination, and reads both saved files.

    Without the fix, the second download reports .playwright-cli/same.txt instead of .playwright-cli/same-1.txt on all four browsers. With the fix, the destinations differ and both contents are preserved.

    All runs were headless on Linux. The CLI save-as and shared file suites passed on Chrome, Chromium, Firefox and WebKit: 81 passed, 7 existing skips. npm run build and npm run flint passed.

    Draft PR: microsoft/playwright#44011

    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

    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