Protocol error(Runtime.callFunctionOn): Target closed.
See original GitHub issueDescription
It happens only if you’re using Proxies, after logging in, when the page redirects you. You get the error, I can’t share the website or the code 😦 When the error occurs, the page is still open, it’s not closed.
Full Error
Protocol error(Runtime.callFunctionOn): Target closed. (NetworkManager failed to process Fetch.requestPaused. Value cannot be null. Parameter name: key. at System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKey key, Func2 valueFactory) at PuppeteerSharp.Helpers.MultiMap
2.Add(TKey key, TValue value)
at PuppeteerSharp.Helpers.AsyncDictionaryHelper2.<GetItemAsync>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PuppeteerSharp.NetworkManager.<OnRequestAsync>d__46.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PuppeteerSharp.NetworkManager.<OnRequestPausedAsync>d__45.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PuppeteerSharp.NetworkManager.<Client_MessageReceived>d__40.MoveNext())
Expected behavior:
Redirects just fine without the error occurring
Actual behavior:
That error occurs
Versions
Latest (2.0.3)
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (12 by maintainers)
Top GitHub Comments
Fixed on #1521 thank you @kerohero! I hope this is the first PR of many to come!
@kblok @Solaflex So I downloaded Puppeteer Sharp code and added it to my project to debug it The problem is in the NetworkManager file, the OnRequestAsync method, specifically in this line
var frame = await FrameManager.TryGetFrameAsync(e.FrameId).ConfigureAwait(false);
e.FrameId being null causes the exception, I gone to check Puppeteer itself and found thisconst frame = event.frameId ? this._frameManager.frame(event.frameId) : null;
As you can see the frame itself can be null so I adjusted the code to bevar frame = !string.IsNullOrEmpty(e.FrameId) ? await FrameManager.TryGetFrameAsync(e.FrameId).ConfigureAwait(false) : null;
Works like a charm for me.