Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Cannot transfer files larger than 50Mb to a browser not co-located with the server #34192

Closed
freegar opened this issue Jan 2, 2025 · 11 comments

Comments

@freegar
Copy link

freegar commented Jan 2, 2025

Version

1.49.0

Steps to reproduce

I am confident that this is a problem with Playwright, with the same browser and environment. The same CDP is used, but Puppet is fine, but Playwright is not。Please take this issue seriously

Here is my code:
return await Puppeteer.ConnectAsync(new ConnectOptions()
{
BrowserWSEndpoint = endpointURL,
DefaultViewport = null
});

playwright not:
return await playwright.Chromium.ConnectOverCDPAsync(
wsEndpointUrl,
new BrowserTypeConnectOverCDPOptions { Timeout = 10 * 60 * 1000 });
}

same fingerprint browser,Puppeteer can upload more than 50M file。if you say it is google question,the probably using something like connectOverCDP()。so please tell me ,how i can upload more than 50M file .After all, Puppet can achieve

Expected behavior

My implementation requirement is to connect Playwright to a fingerprint browser using CDP. Puppeteer can perfectly meet this requirement by uploading files over 100M, but Playwright cannot meet this requirement as he can only upload files smaller than 50M. Is this a problem with Google Chrome? Puppeteer. Firefox,Puppeteer. Webkit,Puppeteer. Google , Not even possible Why does Puppet work, but Playwright doesn't。

Puppeteer ConnectAsync code:

public async Task ConnectAsync(ConnectOptions options)
{
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}

EnsureSingleLaunchOrConnect();

if (!string.IsNullOrEmpty(options.BrowserURL) && !string.IsNullOrEmpty(options.BrowserWSEndpoint))
{
throw new PuppeteerException("Exactly one of browserWSEndpoint or browserURL must be passed to puppeteer.connect");
}

Connection connection = null;
try
{
var browserWSEndpoint = string.IsNullOrEmpty(options.BrowserURL)
? options.BrowserWSEndpoint
: await GetWSEndpointAsync(options.BrowserURL).ConfigureAwait(false);

connection = await Connection.Create(browserWSEndpoint, options, _loggerFactory).ConfigureAwait(false);

var version = await connection.SendAsync<BrowserGetVersionResponse>("Browser.getVersion").ConfigureAwait(false);

var product = version.Product.ToLower(CultureInfo.CurrentCulture).Contains("firefox")
  ? SupportedBrowser.Firefox
  : SupportedBrowser.Chromium;

var response = await connection.SendAsync<GetBrowserContextsResponse>("Target.getBrowserContexts").ConfigureAwait(false);
return await CdpBrowser
    .CreateAsync(
        product,
        connection,
        response.BrowserContextIds,
        options.IgnoreHTTPSErrors,
        options.DefaultViewport,
        null,
        options.TargetFilter,
        options.IsPageTarget,
        options.InitAction)
    .ConfigureAwait(false);

}
catch (Exception ex)
{
connection?.Dispose();
throw new ProcessException("Failed to create connection", ex);
}

Actual behavior

When uploading large file, about 100MB, page.SetFilesAsync fails

Additional context

I saw someone ask a issues before two years ago。#3768
but there is no follow-up solution available

Environment

- Operating System: Windows
- CPU: [arm64]
- Browser: Chromium
- .NET Version (TFM): [net core 8.0]
- Other info:
@freegar
Copy link
Author

freegar commented Jan 2, 2025

same fingerprint browser,Puppeteer can upload more than 50M file。if you say it is google question,the probably using something like connectOverCDP()。so please tell me ,how i can upload more than 50M file .After all, Puppet can achieve

@freegar
Copy link
Author

freegar commented Jan 2, 2025

I want to emphasize that Puppet can meet these requirements. I hope you don't casually close the issue and blame it on Google Chrome, at least provide a solution

@frank9306
Copy link

I had the same problem and hope to get some ideas

@Skn0tt
Copy link
Member

Skn0tt commented Jan 3, 2025

Hi folks! This limit is only put in place for non-local browsers, because of network limits in how CDP communicates. If you run the browser locally, so without connectOverCDP, you'll be able to upload arbitrarily big files. Is your browser local or remote? What are you trying to achieve?

@freegar
Copy link
Author

freegar commented Jan 3, 2025

Hi folks! This limit is only put in place for non-local browsers, because of network limits in how CDP communicates. If you run the browser locally, so without connectOverCDP, you'll be able to upload arbitrarily big files. Is your browser local or remote? What are you trying to achieve?

Hi, I am opening a local browser and my cookie is stored in an app, so I am using WS to open a browser。
After opening it, I need to use this browser to open a webpage and upload files. Now I need to upload large files, such as 100MB@Skn0tt

@Skn0tt
Copy link
Member

Skn0tt commented Jan 3, 2025

For local browsers, try launchPersistentContext instead of connectOverCDP. That won't have the upload file limitation.

@freegar
Copy link
Author

freegar commented Jan 3, 2025

@Skn0tt,my ws address is ws://127.0.0.1:4805/devtools/browser/e8e89710-ef27-4a86-a586-9e8dbcdfc0af,I use it to launch my browser,it is not a directory

@Skn0tt
Copy link
Member

Skn0tt commented Jan 3, 2025

The CDP-based approach has the upload limitations you hit. If you want to upload big files, use launchPersistentContext.

@Skn0tt Skn0tt closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2025
@freegar
Copy link
Author

freegar commented Jan 3, 2025

@Skn0tt ,ws://127.0.0.1:4805/devtools/browser/e8e89710-ef27-4a86-a586-9e8dbcdfc0af
My address is this, it's not a directory, you say LaunchPersistentContextAsync,It's clearly not what I hoped for, it can't solve my problem
await BrowserType.LaunchPersistentContextAsync(userDataDir, options);
userDataDir :Path to a User Data Directory
It seems that you didn't understand my question, but simply provided an answer based on whether I am a local browser or not

@freegar
Copy link
Author

freegar commented Jan 3, 2025

It seems that you are not aware of this issue, and Playwright currently does not have a solution。You attribute him to CDP restrictions,What I need to clarify is that Puppeteer can meet this requirement

@freegar
Copy link
Author

freegar commented Jan 3, 2025

please keep open about the Issues,let other give us some Suggestions or solutions。thank you。@Skn0tt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants