question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: after about 833 times different context running with same browser, browser close automatically

See original GitHub issue

Playwright version

1.12.2

Operating system

Windows

What browsers are you seeing the problem on?

WebKit

Other information

.NET 5.0.301

What happened? / Describe the bug

I use playwright in a background service in .NET 5 console project. I use DI to run playwright to browser some websites and wait for response, get some attributes, like _browserContext.NewPageAsync(), page.GotoAsync, page.WaitForResponseAsync, page.GetAttributeAsync, response.TextAsync() and something like these methods. But every time when run to about No.833+ contexts (I will dispose one after one every time) public async void Dispose() { await _browserContext.CloseAsync(); await _browserContext.DisposeAsync(); GC.SuppressFinalize(this); } with one browser but different context, about 833times later, browser will automatically down. Logs below. Is there anything I did wrong? Thanks developer and community! Forgive my bad English.

Code snippet to reproduce your bug

services.TryAddSingleton<IPlaywright>(Playwright.CreateAsync().Result);
            services.TryAddSingleton<IBrowser>(provider =>
            {
                var playwright = provider.GetService<IPlaywright>();
                if (playwright != null)
                    return playwright.Webkit.LaunchAsync().Result;
                throw new Exception("Fail");
            });
            services.TryAdd(new ServiceDescriptor(typeof(IBrowserContext), provider =>
            {
                var browser = provider.GetService<IBrowser>();
                var context = browser!.NewContextAsync(new BrowserNewContextOptions()
                {
                    UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
                    ExtraHTTPHeaders = new List<KeyValuePair<string, string>>()
                    {
                        new ("Accept-Language","en-US,en;q=0.9")
                    }
                }).Result;
                context.SetDefaultNavigationTimeout(6_000);
                context.SetDefaultTimeout(6_000);
                return context;
            }, contextLifetime));

Relevant log output

`Microsoft.Playwright.PlaywrightException: Protocol error (Dialog.enable): Browser closed.
==================== Browser output: ====================
<launching> C:\Users\Administrator\AppData\Local\ms-playwright\webkit-1492\Playwright.exe --inspector-pipe --headless --no-startup-window
<launched> pid=15044
[pid=15044][err] 1   00007FFF46981089
[pid=15044][err] 2   00007FFF469F7C59
[pid=15044][err] 3   00007FFF469A4B75
[pid=15044][err] 4   00007FFF469F497E
[pid=15044][err] 5   00007FFF469A863F
[pid=15044][err] 6   00007FFF469F8F59
[pid=15044][err] 7   00007FFF698D268A
[pid=15044][err] 8   00007FFF6C6F7974
[pid=15044][err] 9   00007FFF6D06A2F1
[pid=15044] <process did exit: exitCode=3221225477, signal=null>
[pid=15044] starting temporary directories cleanup
[pid=15044] finished temporary directories cleanup
   at Microsoft.Playwright.Transport.Connection.SendMessageToServerAsync[T](String guid, String method, Object args)
   at Microsoft.Playwright.BrowserContext.NewPageAsync()`

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
LuohuaRaincommented, Aug 26, 2021

please help me review this issue. @kblok @avodovnik @Meir017 @pavelfeldman @SimonCropp @slang25 @ScottHuangZL @aslushnikov thank you my teachers

1reaction
LuohuaRaincommented, Aug 24, 2021

And the example I used was single-threaded and did not involve parallel or multi-threaded at all

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug #1076350 “Crash when navigating to another page ...
Crash when navigating to another page immediately after initializing unity integration. Bug #1076350 reported by Chris Coulson on 2012-11-08.
Read more >
Chromedriver closing after test
However when running my tests, it seems that even without calling driver.quit and instead calling pass, that the window still closes. I'm using ......
Read more >
Security: heap-use-after-free in ProfileImpl::IsSameOrParent
For debug purposes, setting a breakpoint in DevTools at `chrome.webstorePrivate.completeInstall(` works the same. Now, closing the browser ...
Read more >
How to Fix Website is Not Secure Error in Chrome - Support.com
Learn what security and secure sites mean for Google and how to correct an improperly flagged site so you can access it.
Read more >
Automatically close chrome - Studio
There suddenly has a bug is that robot automatically closes chrome in running. For example: Normally, robot will click to button to open...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found