Skip to content

Unhandled exception in PuppeteerSharp/Cdp/CdpHttpRequest.cs:line 45 #2809

@400ochkov

Description

@400ochkov

Hello, I faced unhandled exception and my program closed due to it

Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException: Cannot read invalid UTF-16 JSON text as string. Invalid surrogate value: '0xDF30'.
   at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ReadInvalidUTF16(Int32 charAsInt)
   at System.Text.Json.JsonReaderHelper.TryUnescape(ReadOnlySpan`1 source, Span`1 destination, Int32 idx, Int32& written)
   at System.Text.Json.JsonReaderHelper.GetUnescapedString(ReadOnlySpan`1 utf8Source)
   at System.Text.Json.JsonElement.ToString()
   at PuppeteerSharp.Cdp.CdpHttpRequest..ctor(CDPSession client, IFrame frame, String interceptionId, Boolean allowInterception, RequestWillBeSentResponse data, List`1 redirectChain, ILoggerFactory loggerFactory) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Cdp/CdpHttpRequest.cs:line 45
   at PuppeteerSharp.Cdp.NetworkManager.OnRequestWithoutNetworkInstrumentationAsync(CDPSession client, FetchRequestPausedResponse e) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Cdp/NetworkManager.cs:line 452
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
   at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()

Is it possible to handle it somehow? It's not my fault, no any path to my code in stack
I faced it when run my programm in many threads, but I can't share here all my code, I hope your understand...
Just add try { ... } catch {...} in PuppeteerSharp/Cdp/CdpHttpRequest.cs:line 45 and I think it will be good

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions