playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] Unable to upload big file on firefox.

Open niyarlatotep opened this issue 5 years ago • 9 comments

Context:

  • Playwright Version: 1.6.2
  • Operating System: Win 10
  • Node.js version: 14
  • Browser: Firefox

Code Snippet

const {firefox} = require('playwright');
const path = require('path');

(async function() {
    const browser = await firefox.launch({headless: false});
    try {
        const page = await browser.newPage();
        await page.goto('https://pdf.io/compress/');
        await page.setInputFiles('#upload_button input', path.join(process.cwd(), 'big.pdf'));
    } finally {
        await browser.close();
    }
})();

Describe the bug

When I try to upload big pdf, for example this one: http://research.nhm.org/pdfs/29985/29985-001.pdf I get an error in example unable to upload file. At the same time chrome uploads file well, also small files are uploaded well on firefox but big ones don't.

niyarlatotep avatar Dec 14 '20 14:12 niyarlatotep

(I edited your script to include missing requires)

I unfortunately cannot reproduce - worked fine for me on both Mac OS and Windows 10 Enterprise. Any more specifics that would help reproducing this?

aslushnikov avatar Dec 14 '20 15:12 aslushnikov

@aslushnikov I'm sorry it seems that I missed some important details. Try to comment await browser.close() and see what happens in browser window at the end of uploading process it takes some time then website says that it unable to upload file. I don't know if it website problem or not, but on chrome browser it works fine.

niyarlatotep avatar Dec 15 '20 06:12 niyarlatotep

Still working on a fix, but I can repro this on ubuntu 20.04 with firefox. It doesn't happen when I manually click the input and select the file, so something is messed up with our setInputFiles.

I get this error in the console when it fails. Very strange.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://s104.123apps.com/pdf/upload/flow/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

It doesn't happen with the old juggler Page.setInputFiles. Only our new userland approach.

JoelEinbinder avatar Feb 04 '21 22:02 JoelEinbinder

I've hit the same problem with Firefox recently - large file uploads don't work at all.

Here's a repro case with no dep on any third party service, just an echo server: https://github.com/achingbrain/playwright-ff-uploads

achingbrain avatar Apr 26 '21 12:04 achingbrain

@pavelfeldman, @JoelEinbinder are there any plans to fix it?

niyarlatotep avatar May 09 '21 08:05 niyarlatotep

@achingbrain thank you for the awesome repro.

This happens due to the way our network instrumentation interacts with POST data in Juggler. Specifically, it looks like NetUtil.readInputStream call is both: a) racy & partial b) closing the stream, making the final rewind-back fail.

Note that this all only happens with Blob uploads as POST requests.

aslushnikov avatar May 12 '21 09:05 aslushnikov

This is fixed now; the fix will be available in the next release - Playwright v1.12

Or on May 14 PST time in the @next channel: npm i playwright@next

aslushnikov avatar May 13 '21 21:05 aslushnikov

The issue still exists as soon as I go above 500kb file size the setInputFiles stuck on waiting on Firefox, same code on other browsers works just fine.

"playwright": "1.27.1", Any suggestions?

Saif4 avatar Nov 01 '22 09:11 Saif4

@Saif4 please file separately with a repro!

aslushnikov avatar Nov 02 '22 20:11 aslushnikov