playwright: [BUG] File uploads fail which are > 50 MB
Context:
- Playwright Version: 1.3.0
- Operating System: Windows
- Node.js version: 12.18.3
- Browser: Chromium
Code Snippet
const { chromium } = require("playwright");
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.setContent(
'<input type="file" name="fileToUpload" id="fileToUpload">'
);
await page.setInputFiles("input", "path/to/large/file.txt");
await browser.close();
})();
Describe the bug
When uploading large file, about 100MB, page.setInputFiles fails. With Firefox and Webkit it takes some time but it works.
Log:
pw:api => page.setContent started +0ms
pw:api setting frame content, waiting until "load" [] +1ms
pw:api <= page.setContent succeeded +79ms
pw:api => page.setInputFiles started +2ms
pw:api waiting for selector "input" [] +1ms
pw:api selector resolved to visible <input type="file" id="fileToUpload" name="fileToUpload"/> [] +26ms
pw:api <= page.setInputFiles failed +1s
(node:19668) UnhandledPromiseRejectionWarning: page.setInputFiles: Protocol error (Runtime.callFunctionOn): Target closed.
=========================== logs ===========================
[api] waiting for selector "input"
[api] selector resolved to visible <input type="file" id="fileToUpload" name="fileToUpload"/>
============================================================
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.Error
at C:\dev\playwright\node_modules\playwright\lib\chromium\crConnection.js:131:63
at new Promise (<anonymous>)
at CRSession.send (C:\dev\playwright\node_modules\playwright\lib\chromium\crConnection.js:130:16)
at CRSession.send (C:\dev\playwright\node_modules\playwright\lib\helper.js:80:31)
at CRExecutionContext.evaluateWithArguments (C:\dev\playwright\node_modules\playwright\lib\chromium\crExecutionContext.js:40:79)
at evaluateExpression (C:\dev\playwright\node_modules\playwright\lib\javascript.js:164:40)
at async FrameManager.waitForSignalsCreatedBy (C:\dev\playwright\node_modules\playwright\lib\frames.js:90:24)
at async FrameExecutionContext.evaluateInternal (C:\dev\playwright\node_modules\playwright\lib\dom.js:36:16)
at async CRPage.setInputFiles (C:\dev\playwright\node_modules\playwright\lib\chromium\crPage.js:210:9)
at async C:\dev\playwright\node_modules\playwright\lib\dom.js:440:13
-- ASYNC --
at CRSession.send (C:\dev\playwright\node_modules\playwright\lib\helper.js:79:23)
at CRExecutionContext.evaluateWithArguments (C:\dev\playwright\node_modules\playwright\lib\chromium\crExecutionContext.js:40:79)
at evaluateExpression (C:\dev\playwright\node_modules\playwright\lib\javascript.js:164:40)
at async FrameManager.waitForSignalsCreatedBy (C:\dev\playwright\node_modules\playwright\lib\frames.js:90:24)
at async FrameExecutionContext.evaluateInternal (C:\dev\playwright\node_modules\playwright\lib\dom.js:36:16)
at async CRPage.setInputFiles (C:\dev\playwright\node_modules\playwright\lib\chromium\crPage.js:210:9)
at async C:\dev\playwright\node_modules\playwright\lib\dom.js:440:13
at async FrameManager.waitForSignalsCreatedBy (C:\dev\playwright\node_modules\playwright\lib\frames.js:90:24)
at async ElementHandle._setInputFiles (C:\dev\playwright\node_modules\playwright\lib\dom.js:438:9)
at async C:\dev\playwright\node_modules\playwright\lib\frames.js:674:32
-- ASYNC --
at Frame.setInputFiles (C:\dev\playwright\node_modules\playwright\lib\helper.js:79:23)
at C:\dev\playwright\node_modules\playwright\lib\page.js:407:61
at Page._attributeToPage (C:\dev\playwright\node_modules\playwright\lib\page.js:370:20)
at Page.setInputFiles (C:\dev\playwright\node_modules\playwright\lib\page.js:407:21)
at Page.setInputFiles (C:\dev\playwright\node_modules\playwright\lib\helper.js:80:31)
at C:\dev\playwright\upload.js:9:14
(node:19668) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:19668) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 55
- Comments: 39 (6 by maintainers)
I’m trying to prioritize this, could you share what kind of testing scenario requires uploading 100Mb+ files?
hey, any updates?
Seeing the same issue for files ranging from 90MB to 320MB. Any workarounds?
any updates?
Hello @pavelfeldman. We would like to use it for end to end testing of our in vitro diagnostic medical application. The crash appear during upload/download genomic and other medical files (170mo to 5go and bigger files).
Large file uploads also seem to be slow. (30 seconds for 70 megabytes). I think it might be caused by this byte-by-byte mapping of the content of the target file / buffer.
https://github.com/microsoft/playwright/blob/06ab3c0fda2223ef6fd813c48373208b1b2c01b7/packages/playwright-core/src/server/injected/injectedScript.ts#L660
In my case, I used playwright to upload video files to video hosting under test.
The website (AI training purposes) allowed user to upload video files. In machine learning model, each video file minimally exceed 2GB.
This is what I get when running with
DEBUG=pw:browser*:Here is the Chromium max buffer size.
Hello! I am still unable to upload files (500 mb and 2gb files) as the test would hang. It only works for small files.
Context:
Playwright Version: 1.25.2 Operating System: Mac OS 12.5.1 Python Version: 3.7.9 Browser: Chromium
Hello @mxschmitt @pavelfeldman
Are there still blockers for this issue? Do you need additional information?
Cheers
@mxschmitt I see you assigned the issue to yourself and even added a label for a fix version, but removed both later on. Are there any plans to get this issue fixed in the near future?
@pavelfeldman In my case, I’m uploading some files which are 200 MB (firmware update and some patches inside). Currently this issue is blocking the Jenkins pipeline since all tests are failing. Any workaround?
In my case, I am testing a vmware-like web app, which requires user to upload OS .iso file / VM .ova file which is usually larger than 1GB.
Maybe a begin of a workaround … (@joel-s) Increasing cache memory size of the browser at launching with parameters regarding to @dgozman browser error. I saw here how to increase cache memory depending of browser used and playwrith api to set config at browser launching
Testing with Chrome It should be something like this :
Chrome is nicely launched with this param and others which seems to be playwright’s defaults args :
BUT
Cache still little… 😭

Testing with Firefox It should be something like this :
But still failing as shawn in my previous post whereas when adding a
page.waitForTimeout(xxxx)I can manualy check theabout:configand params are goodly set as I wanted… so maybe not a “cache-problem” with firefox…I’m loosing faith… Have you got any idea ? Am I missing something ?
Exactly same problem here. I had troubles with node memory when I uploaded multiples small files one after an other so I added
export NODE_OPTIONS=--max_old_space_size=4096to force memory of node to 4gb.Then I realised that playwright didn’t throw unused memory in a scenario If you don’t manually reset the context of the browser. ( happened for me also by uploading many small files )
But now, I still have a problem when uploading a simple file of more than 300Mo… This is what I got as error (nothing in pw:browser) :
What I find curious is that I used Firefox as testing browser and it talks about chrome…
Ubuntu 20.04 LTS, playwright 1.7.0