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

Unrecoverable exceptions being frequently thrown #717

Closed
lloydjatkinson opened this issue Oct 26, 2018 · 32 comments · Fixed by #720
Closed

Unrecoverable exceptions being frequently thrown #717

lloydjatkinson opened this issue Oct 26, 2018 · 32 comments · Fixed by #720

Comments

@lloydjatkinson
Copy link

lloydjatkinson commented Oct 26, 2018

Description

Unrecoverable exceptions are being thrown by Puppeteer Sharp. This prevents any kind of retry or graceful exception handling and results in the process being terminated.

Complete minimal example reproducing the issue

    // Arrange
            var launchOptions = new LaunchOptions()
            {
                Headless = true,
            };

            var viewPortOptions = new ViewPortOptions()
            {
                Width = 1920,
                Height = 1080
            };

            var sites = new List<string>()
            {
                "wix.com",
                "facebook.com",
                "twitter.com",
                "google.com",
                "youtube.com",
                "instagram.com",
                "linkedin.com",
                "wordpress.org",
                "pinterest.com",
                "wikipedia.org",
                "wordpress.com",
                "blogspot.com",
                "apple.com",
                "adobe.com",
                "tumblr.com",
            }
    // Act
            try
            {
                await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
                using (var browser = await Puppeteer.LaunchAsync(launchOptions))
                {
                    //var context = await browser.CreateIncognitoBrowserContextAsync();
                    //var page = await context.NewPageAsync();
                    var page = await browser.NewPageAsync();
                    await page.SetViewportAsync(viewPortOptions);

                    foreach (var site in sites)
                    {
                        try
                        {
                            await page.GoToAsync($"http://{site}");
                            Console.WriteLine(await page.GetTitleAsync());
                            await page.ScreenshotAsync($"D:\\bin\\screenshots\\{site}.png");
                        }
                        catch (Exception exception)
                        {
                            // Catches most exceptions such as timeouts but does not catch others, see below.
                            Console.WriteLine($"Unable to take screenshot of: {site}. Exception: {exception.Message}");
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                // Never enters the catch.
                Console.WriteLine($"Unable to proceed: {exception.Message}");
            }

Expected behavior:

The library to take a screenshot of the URL given.

Actual behavior:

Often crashes with exceptions which cannot be caught. There appears to be no common cause of the issue and it happens at random. The issue does not seem to be related to a particular site.

Same happens with normal and Incognito sessions.

Versions

  • Which version of PuppeteerSharp are you using? 1.8.0
  • Which .NET runtime and version are you targeting? .NET Core 2.1

Additional Information

The exceptions are lacking in details and so far the exceptions encountered are:

image

PuppeteerSharp.TargetCrashedException
  HResult=0x80131500
  Source=PuppeteerSharp
  StackTrace:
   at PuppeteerSharp.Page.OnTargetCrashed()
   at PuppeteerSharp.Page.<Client_MessageReceived>d__199.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
System.Collections.Generic.KeyNotFoundException
  HResult=0x80131577
  Message=The given key 'B99316384B7CE098D1E12423B7A2772B' was not present in the dictionary.
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowKeyNotFoundException[T](T key)
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at PuppeteerSharp.NetworkManager.OnRequest(RequestWillBeSentPayload e, String interceptionId)
   at PuppeteerSharp.NetworkManager.OnRequestWillBeSent(RequestWillBeSentPayload e)
   at PuppeteerSharp.NetworkManager.<Client_MessageReceived>d__33.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

Here is the redirected output from Chrome. Again because this happens randomly I haven't been able to determine an exact reproduction but it seems to happen more often when it navigates to a site that does not exist.

Unable to take screenshot of: wixsite.com. Exception: net::ERR_NAME_NOT_RESOLVED
 at http://wixsite.com at http://wixsite.com
Received fatal exception EXCEPTION_ACCESS_VIOLATION
Backtrace:
        GetHandleVerifier [0x00007FF9B8058D94+15468820]
        ovly_debug_event [0x00007FF9B6A08B5D+16084829]
        ovly_debug_event [0x00007FF9B6A088B7+16084151]
        ovly_debug_event [0x00007FF9B69FC185+16033157]
        ovly_debug_event [0x00007FF9B69FBA36+16031286]
        ovly_debug_event [0x00007FF9B69F764B+16013899]
        GetHandleVerifier [0x00007FF9B80583D0+15466320]
        GetHandleVerifier [0x00007FF9B77C89CC+6489420]
        GetHandleVerifier [0x00007FF9B77C8560+6488288]
        GetHandleVerifier [0x00007FF9B77C9A01+6493569]
        ovly_debug_event [0x00007FF9B626E19A+8111514]
        GetHandleVerifier [0x00007FF9B72C4E0F+1231247]
        GetHandleVerifier [0x00007FF9B72C3384+1224452]
        IsSandboxedProcess [0x00007FF9B71781BC+1557308]
        IsSandboxedProcess [0x00007FF9B718C3E6+1639782]
        IsSandboxedProcess [0x00007FF9B71781BC+1557308]
        ovly_debug_event [0x00007FF9B6CC0C4F+18935887]
        ovly_debug_event [0x00007FF9B6CC1045+18936901]
        IsSandboxedProcess [0x00007FF9B717AAF9+1567865]
        ovly_debug_event [0x00007FF9B6CD96D1+19036881]
        IsSandboxedProcess [0x00007FF9B713319E+1274654]
        ovly_debug_event [0x00007FF9B6C9A9D3+18779603]
        ovly_debug_event [0x00007FF9B6C9E9C6+18795974]
        ovly_debug_event [0x00007FF9B6C9A191+18777489]
        IsSandboxedProcess [0x00007FF9B716F27D+1520637]
        IsSandboxedProcess [0x00007FF9B716F194+1520404]
        ovly_debug_event [0x00007FF9B6C9CCAE+18788526]
        ChromeMain [0x00007FF9B5AB1111+273]
        Ordinal0 [0x00007FF7F23531CC+12748]
        Ordinal0 [0x00007FF7F235168D+5773]
        GetHandleVerifier [0x00007FF7F24557E2+793282]
        BaseThreadInitThunk [0x00007FFA016A13D2+34]
        RtlUserThreadStart [0x00007FFA036354F4+52]

As a side effect dozens of Chromium instances are left running, though that's not really within scope of this issue.

image

@kblok
Copy link
Member

kblok commented Oct 28, 2018

Are you getting this locally or on a server?

@lloydjatkinson
Copy link
Author

lloydjatkinson commented Oct 28, 2018

This is local yes. Is there anything else I can do to assist in finding the problem?

@kblok
Copy link
Member

kblok commented Oct 28, 2018

I just published v1.9. Could you give it a try?

@lloydjatkinson
Copy link
Author

System.ArgumentException
  HResult=0x80070057
  Message=An item with the same key has already been added. Key: 1000023304.14
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException[T](T key)
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at PuppeteerSharp.NetworkManager.OnRequest(RequestWillBeSentPayload e, String interceptionId)
   at PuppeteerSharp.NetworkManager.OnRequestWillBeSent(RequestWillBeSentPayload e)
   at PuppeteerSharp.NetworkManager.<Client_MessageReceived>d__36.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

I'm getting this exception, similar randomness as to when it occurs.

@lloydjatkinson
Copy link
Author

So far I've not seen TargetCrashedException being thrown so the new update has been able to fix part of the problem 👍

@kblok
Copy link
Member

kblok commented Oct 28, 2018

@lloydjatkinson Could you create a solution including Puppeteer-Sharp source code so we can code from there?

We can protect that "TryInsert" but as I can't reproduce it, I don't know if those change will be the final fix.

@lloydjatkinson
Copy link
Author

lloydjatkinson commented Oct 28, 2018

Yeah sure! I've forked the repo and added a new .NET Core Console app.

https://github.com/lloydjatkinson/puppeteer-sharp/commit/3e55492d50a0e5bd5093905e3c3985a70c02bbe5

image

System.ArgumentException
  HResult=0x80070057
  Message=An item with the same key has already been added. Key: 1000047964.123
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException[T](T key)
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at PuppeteerSharp.NetworkManager.OnRequest(RequestWillBeSentPayload e, String interceptionId) in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\NetworkManager.cs:line 282
   at PuppeteerSharp.NetworkManager.OnRequestWillBeSent(RequestWillBeSentPayload e) in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\NetworkManager.cs:line 348
   at PuppeteerSharp.NetworkManager.<Client_MessageReceived>d__36.MoveNext() in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\NetworkManager.cs:line 106

Here's the exact environment:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.401
 Commit:    91b1c13032

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.3.9600
 OS Platform: Windows
 RID:         win81-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.401\

Host (useful for support):
  Version: 2.1.3-servicing-26724-03
  Commit:  124038c13e
Node: v10.1.0

@kblok
Copy link
Member

kblok commented Oct 28, 2018

Could you test this branch?
#720

@lloydjatkinson
Copy link
Author

I've tested with that branch and I am getting the exception as before, but much much less frequently.

@kblok
Copy link
Member

kblok commented Oct 29, 2018

@lloydjatkinson which one? Could you share another stack trace?

@lloydjatkinson
Copy link
Author

Sure yeah.

System.Collections.Generic.KeyNotFoundException
  HResult=0x80131577
  Message=The given key '1FBE64BB0B3959DF837EFDA319DEB9C7' was not present in the dictionary.
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowKeyNotFoundException[T](T key)
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at PuppeteerSharp.FrameManager.OnExecutionContextCreated(ContextPayload contextPayload) in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 232
   at PuppeteerSharp.FrameManager._client_MessageReceived(Object sender, MessageEventArgs e) in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 174
   at PuppeteerSharp.CDPSession.OnMessage(String message) in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\CDPSession.cs:line 259
   at PuppeteerSharp.Connection.<Transport_MessageReceived>d__33.MoveNext() in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\Connection.cs:line 227

@kblok
Copy link
Member

kblok commented Oct 30, 2018

@lloydjatkinson I think I found the root of these issues, but it requires some refactors. I'm working on it.

@lloydjatkinson
Copy link
Author

Ok great, thank you for looking into it. Out of curiosity, how is it the exceptions are not able to be caught? Being thrown in a different thread or something similar?

@kblok
Copy link
Member

kblok commented Oct 30, 2018

According to dotnet/roslyn#13897 (comment)

async void with an unhandled exception brings down the process

These are the two issues, I believe, we have. We are doing async void to process WebSocket messages. If some method fails there, the entire process goes down.
The second problem is that if we call async void events using Event?.Invoke those async methods become fire-and-forget tasks. So the problem we might be getting is that, when we get a targetCreated event, we invoke it, but then we start invoking other events (that need the new target) while the task creating the target didn't finish yet.

cc @Meir017

@kblok
Copy link
Member

kblok commented Oct 31, 2018

Could you pull from support/onrequest-changes again @lloydjatkinson?

@kblok
Copy link
Member

kblok commented Nov 1, 2018

Did you have the chance to test it @lloydjatkinson ?

@lloydjatkinson
Copy link
Author

Hi @kblok I'm testing it now, sorry for the delay.

@lloydjatkinson
Copy link
Author

lloydjatkinson commented Nov 1, 2018

I've run a few hours of testing and the issue seems to have been resolved and no process termination 👍 Thanks!

I have however come across a new edge case. I'm not sure if it belongs in this issue or a new one though.

When in headless mode navigating to http://one.com causes the Windows/Console beep to occur - every time the site is hit (I've not encountered this on any other site). When not running in headless mode and hitting the same site and with SlowMo enabled, however, the console beeps are not emitted and I get the following exceptions (not in any particular order).

Let me know if this is better suited in a new issue!

System.InvalidOperationException
  HResult=0x80131509
  Message=Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported()
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
   at PuppeteerSharp.Browser.<CreateTargetAsync>d__63.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\Browser.cs:line 399
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PuppeteerSharp.Browser.<Connect_MessageReceived>d__60.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\Browser.cs:line 335
System.InvalidOperationException
  HResult=0x80131509
  Message=An attempt was made to transition a task to a final state when it had already completed.
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at PuppeteerSharp.Frame.SetDefaultContext(ExecutionContext context) in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\Frame.cs:line 644
   at PuppeteerSharp.FrameManager.<OnExecutionContextCreatedAsync>d__44.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 247
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PuppeteerSharp.FrameManager.<_client_MessageReceived>d__39.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 178
System.IndexOutOfRangeException
  HResult=0x80131508
  Message=Index was outside the bounds of the array.
  Source=System.Collections
  StackTrace:
   at System.Collections.Generic.HashSet`1.Enumerator.MoveNext()
   at PuppeteerSharp.FrameManager.AddFrame(String framId, Frame frame) in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 305
   at PuppeteerSharp.FrameManager.OnFrameNavigated(FramePayload framePayload) in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 292
   at PuppeteerSharp.FrameManager.<_client_MessageReceived>d__39.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 162
System.IndexOutOfRangeException
  HResult=0x80131508
  Message=Index was outside the bounds of the array.
  Source=System.Collections
  StackTrace:
   at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value)
   at System.Collections.Generic.HashSet`1.Add(T item)
   at PuppeteerSharp.Helpers.MultiMap`2.Add(TKey key, TValue value) in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\Helpers\MultiMap.cs:line 15
   at PuppeteerSharp.FrameManager.<GetFrameAsync>d__54.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 376
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at PuppeteerSharp.FrameManager.<OnExecutionContextCreatedAsync>d__44.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 236
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PuppeteerSharp.FrameManager.<_client_MessageReceived>d__39.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 178
System.IndexOutOfRangeException
  HResult=0x80131508
  Message=Index was outside the bounds of the array.
  Source=System.Collections
  StackTrace:
   at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value)
   at System.Collections.Generic.HashSet`1.Add(T item)
   at PuppeteerSharp.Helpers.MultiMap`2.Add(TKey key, TValue value) in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\Helpers\MultiMap.cs:line 15
   at PuppeteerSharp.FrameManager.<GetFrameAsync>d__54.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 376
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at PuppeteerSharp.FrameManager.<OnExecutionContextCreatedAsync>d__44.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 236
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PuppeteerSharp.FrameManager.<_client_MessageReceived>d__39.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 178
System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=System.Private.CoreLib
  StackTrace:
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
   at PuppeteerSharp.Browser.<CreateTargetAsync>d__63.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\Browser.cs:line 394
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PuppeteerSharp.Browser.<Connect_MessageReceived>d__60.MoveNext() in C:\Users\Lloyd\Source\Repos\lloydjatkinson\puppeteer-sharp\lib\PuppeteerSharp\Browser.cs:line 335

image

@kblok
Copy link
Member

kblok commented Nov 3, 2018

@lloydjatkinson could you pull again :)

@lloydjatkinson
Copy link
Author

lloydjatkinson commented Nov 3, 2018

I've pulled latest but unfortunately I'm not able to run it to test as I'm getting:

System.Net.WebException
  HResult=0x80070020
  Message=An exception occurred during a WebClient request.
  Source=System.Private.CoreLib
  StackTrace:
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PuppeteerSharp.BrowserFetcher.<DownloadAsync>d__21.MoveNext() in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\BrowserFetcher.cs:line 182

Inner Exception 1:
IOException: The process cannot access the file 'C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\ConsoleApp1\bin\Debug\netcoreapp2.1\.local-chromium\download-Win64-594312.zip' because it is being used by another process.

image

I've restarted to make sure there really are no locks but no luck. Are you able to reproduce this?

@kblok
Copy link
Member

kblok commented Nov 3, 2018

@lloydjatkinson tests are green on the CI. Could you try removing the .local-chromium directory?

@lloydjatkinson
Copy link
Author

lloydjatkinson commented Nov 3, 2018

I tried doing that but I was getting the same problem. I've temporarily copied over a .local-chromium directory from another project.

I get the following exception whenever I try run:

Newtonsoft.Json.JsonSerializationException
  HResult=0x80131500
  Message=Error converting value "javascript" to type 'PuppeteerSharp.TargetType'. Path 'params.entry.source', line 1, position 67.
  Source=Newtonsoft.Json
  StackTrace:
   at Newtonsoft.Json.Converters.StringEnumConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at PuppeteerSharp.Helpers.FlexibleStringEnumConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\Helpers\FlexibleStringEnumConverter.cs:line 20

Inner Exception 1:
ArgumentException: Requested value 'javascript' was not found.

Should that be another issue or is it related to the changes for this issue?

@kblok
Copy link
Member

kblok commented Nov 3, 2018

Could you pull again @lloydjatkinson ?

@lloydjatkinson
Copy link
Author

Pulled - seems to be running OK so far 👍

@kblok
Copy link
Member

kblok commented Nov 3, 2018

@lloydjatkinson awesome!
Please let me know next Monday if we are good so we can review and merge my PR.

@lloydjatkinson
Copy link
Author

Sure will do. Just run into one of the frame key exceptions.

System.Collections.Generic.KeyNotFoundException
  HResult=0x80131577
  Message=The given key '2F5FE399B4BA8B8564954DC080CE743E' was not present in the dictionary.
  Source=System.Collections.Concurrent
  StackTrace:
   at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNotFoundException(Object key)
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at PuppeteerSharp.FrameManager.OnFrameNavigated(FramePayload framePayload) in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 264
   at PuppeteerSharp.FrameManager.<_client_MessageReceived>d__39.MoveNext() in C:\Users\Lloyd\Source\Repos\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 163

@kblok
Copy link
Member

kblok commented Nov 4, 2018

Can you pull again @lloydjatkinson ?

@lloydjatkinson
Copy link
Author

All seems OK now 👍 It's hard to tell, the exceptions have sometimes been random and by chance.

@kblok
Copy link
Member

kblok commented Nov 5, 2018

Cool @lloydjatkinson. I'm taking this issue personally :). I'd love to be able to reproduce your scenario locally. Your collaboration helped me to improve the library a lot.

I'll make the PR ready to review but please let me know if you find any other leak.

@lloydjatkinson
Copy link
Author

I'm glad to have helped, that's nice to hear :) Not found any more exceptions yet but if any come up in the future I'll be sure to comment on here/make a new issue.

@myyandar
Copy link

myyandar commented May 23, 2019

Please i need help. I get this error :
image

This is my controller method, the only PuppeteerSharp code I have:

public async Task<JsonResult> InvoiceToPdfFileAsync([FromBody]string hinput)
        {
            var browserFetcher = await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
            browserFetcher.FolderPath = _env.WebRootPath + "files/";
            var browser = await Puppeteer.LaunchAsync(new LaunchOptions
            {
                Headless = true 
            });

            var outputFile = _env.WebRootPath + "files/Invoice.pdf";
            var page = await browser.NewPageAsync();
            await page.GoToAsync("hinput");
            await page.PdfAsync(outputFile);

            return Json(Url.Content(outputFile));
        }

I'm a newbie in crisis.

@kblok
Copy link
Member

kblok commented May 23, 2019

That a permissions issue @myyandar. What you could do is copying the local-chromium folder to a place where the process can execute Chrome, remove the browser fetcher, and then call LaunchAsync setting the ExecutablePath value.

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

Successfully merging a pull request may close this issue.

3 participants