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

SetRequestInterceptionAsync(true) causing Cannot read incomplete UTF-16 JSON text as string with missing low surrogate #2829

Open
Tiggerito opened this issue Nov 24, 2024 · 2 comments

Comments

@Tiggerito
Copy link

Description

Since 20.0.4 my code that uses SetRequestInterceptionAsync(true) can no longer load pages.

Complete minimal example reproducing the issue

Replace (dot) in the URL...

var options = new LaunchOptions { /*  */ };
var chromiumRevision = BrowserFetcher.DefaultRevision;
var browser = await Puppeteer.LaunchAsync(options, chromiumRevision);
var page = browser.NewPageAsync();

await page.SetRequestInterceptionAsync(true);

page.Request += async (sender, e) => await e.Request.ContinueAsync();

await page.GoToAsync("https://trimmingshop(dot)co(dot)uk/", new NavigationOptions
{
    WaitUntil = new[] { WaitUntilNavigation.Networkidle0 }
});

Expected behavior:

Page loads

Actual behavior:

GoToAsync causes an exception.

PuppeteerSharp.NavigationException: 'Navigating frame was detached: NetworkManager failed to process Fetch.requestPaused. The JSON value could not be converted to System.String. Path: $.request.postData | LineNumber: 0 | BytePositionInLine: 85183..    at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   at PuppeteerSharp.Cdp.NetworkManager.Client_MessageReceived(Object sender, MessageEventArgs e)'

Versions

PuppeteerSharp 20.0.4
.NET Core 3.1, .Net 9.0

Additional Information

20.0.3 works fine, but the e.MessageData in page.Client.MessageReceived sometimes throws the same exception when I try to convert it into a JSON string. I'm guessing it is related, but it's not a critical error as I can capture it. It seems that now the code in Client_MessageReceived is also trying to get at that data, and failing.

There was a change to PostData in 20.0.4, which is mentioned in the exception.

#2810

My other issue also seems related:

#2775

@kblok
Copy link
Member

kblok commented Nov 25, 2024

It seems trimmingshop blocked my IP. I can't test this on that website :(

@Tiggerito
Copy link
Author

Try https://www(dot)skinelite(dot)com/

I have a lot of examples.

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

2 participants