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

Disconnect from browser occurs every 20-50 page.GoToAsync() #2031

Closed
xmetacode opened this issue Oct 27, 2022 · 3 comments · Fixed by #2051
Closed

Disconnect from browser occurs every 20-50 page.GoToAsync() #2031

xmetacode opened this issue Oct 27, 2022 · 3 comments · Fixed by #2051

Comments

@xmetacode
Copy link

Hello, following code throws an exception about one time per 20-50 navigations. Every time it is occurs on random link at random time.

  var options = new ConnectOptions();
  options.BrowserWSEndpoint = "ws://127.0.0.1:9222/devtools/browser/dbc9bf45-1b64-4928-a4b3-34e1978237e0b2";

  var browser = await Puppeteer.ConnectAsync(options);
  var page = await browser.NewPageAsync();

  while (true)
  {
      foreach (var website in websites)
      {
          await page.GoToAsync(website, 120_000);
          await Task.Delay(1_000);
      }
  }

Most often exception looks like:
Navigation failed because browser has disconnected! (Connection failed to process Target.attachedToTarget. Protocol error(Page.setLifecycleEventsEnabled): Target closed. (Target.detachedFromTarget). at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PuppeteerSharp.CDPSession.<SendAsync>d__33.MoveNext() in C:\projects\puppeteer-sharp\lib\PuppeteerSharp\CDPSession.cs:line 97 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PuppeteerSharp.FrameManager.<InitializeAsync>d__44.MoveNext() in C:\projects\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 83 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PuppeteerSharp.FrameManager.<OnAttachedToTargetAsync>d__51.MoveNext() in C:\projects\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 258 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PuppeteerSharp.FrameManager.<>c__DisplayClass49_0.<<Client_MessageReceived>b__0>d.MoveNext() in C:\projects\puppeteer-sharp\lib\PuppeteerSharp\FrameManager.cs:line 216)
List of websites (following list - it is just example. errors occur on any links):

  string[] websites = new[]
  {
      "https://www.codeproject.com/",
      "https://github.com/",
      "https://visualstudio.microsoft.com/",
      "https://code.visualstudio.com/",
      "https://www.spyder-ide.org/",
      "https://nodejs.org/en/",
      "https://en.wikipedia.org/",
      "https://www.jetbrains.com/rider/",
      "https://www.jetbrains.com/pycharm/",
      "https://www.anaconda.com/",
      "https://www.python.org/",
  };

VERSIONS:
Chrome browser: Version 106.0.5249.119 (Official Build) (64-bit)
Chrome was started with args: --remote-debugging-port=9222
OS: windows 11 home 64bit
RAM: 32gb
PuppeteerSharp : 8.0.0
.NET framework 4.8

@kblok
Copy link
Member

kblok commented Oct 27, 2022

Can you try with LaunchAsync instead of ConnectAsync?
Just to narrow the issue.

@xmetacode
Copy link
Author

xmetacode commented Oct 28, 2022

I did it (option Headless=false) and received same result: "Navigation failed because browser has disconnected!...".

UPD: right now i have tested it on Windows Server 2019 Base and received same behaviour.

@kblok
Copy link
Member

kblok commented Oct 30, 2022

I was able to reproduce it, and I think puppeter already fixed it here

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

Successfully merging a pull request may close this issue.

2 participants