Skip to content

[BUG] Cannot download a file in /tmp/ with a Snap browser #6485

@regseb

Description

@regseb

Context

System:

  • OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
  • Memory: 8.56 GB / 15.38 GB
  • Container: Yes
$ df   
Sys. de fichiers blocs de 1K   Utilisé Disponible Uti% Monté sur
udev                 8036728         0    8036728   0% /dev
tmpfs                1613108      2348    1610760   1% /run
/dev/sda2          490691512 132868204  332827828  29% /
tmpfs                8065528     45672    8019856   1% /dev/shm
tmpfs                   5120         4       5116   1% /run/lock
tmpfs                8065528         0    8065528   0% /sys/fs/cgroup
...
/dev/loop3            142336    142336          0 100% /snap/chromium/1564
...
/dev/loop10           142336    142336          0 100% /snap/chromium/1568
...
/dev/sda1             523248      8040     515208   2% /boot/efi
...
tmpfs                1613104        84    1613020   1% /run/user/1000

Binaries:

  • Node: 16.1.0 - /usr/bin/node
  • npm: 7.12.0 - /usr/bin/npm
  • Chromium: 90.0.4430.93 snap - /snap/bin/chromium

Languages:

  • Bash: 5.0.17 - /bin/bash

npmPackages:

  • playwright: ^1.10.0 => 1.10.0

Code Snippet

const fs = require("fs/promises");
const { chromium } = require ("playwright");

(async () => {
    const browser = await chromium.launch({
        downloadsPath:  "/tmp/playwright_testcase/",
        executablePath: "/snap/bin/chromium",
    });
    const page = await browser.newPage({ acceptDownloads: true });
    await page.goto("http://test-debit.free.fr/");
    const [download] = await Promise.all([
        page.waitForEvent("download"),
        page.click(`a[href="4096.rnd"]`),
    ]);
    console.log("download...");
    const path = await download.path();
    console.log(`rename ${path}`);
    await fs.rename(path, "/tmp/playwright_testcase/foo.rnd");
    await browser.close();
})();
$ node testcase.js
download...
rename /tmp/playwright_testcase/23325c8d-f9dd-43d7-bb4a-81a70eefba4f
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

[Error: ENOENT: no such file or directory, rename '/tmp/playwright_testcase/23325c8d-f9dd-43d7-bb4a-81a70eefba4f' -> '/tmp/playwright_testcase/foo.rnd'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'rename',
  path: '/tmp/playwright_testcase/23325c8d-f9dd-43d7-bb4a-81a70eefba4f',
  dest: '/tmp/playwright_testcase/foo.rnd'
}

Describe the bug

playwright doesn't download file in /tmp/playwright_testcase/23325c8d-f9dd-43d7-bb4a-81a70eefba4f (I couldn't find if it was downloading it to another directory). Directory /tmp/playwright_testcase/ is created, but it's always empty.

It works in my $HOME (which is on the same partition as /tmp/):

    const browser = await chromium.launch({
        downloadsPath:  "/home/regseb/playwright_testcase/",
        executablePath: "/snap/bin/chromium",
    });

It works with bundled browser:

    const browser = await chromium.launch({
        downloadsPath:  "/tmp/playwright_testcase/",
    });

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