Playwright/Browsers hang when having more than 3 (sometimes 2) instances running at the same time when testing a Blazor Server App
See original GitHub issueContext:
- Playwright Version: 1.23.0
- Operating System: Windows 11
- Node.js version: 16.13.0
- Browser: Chromium, Firefox
Code Snippet
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Firefox.LaunchAsync(
new BrowserTypeLaunchOptions
{
Headless = false
}
);
await Parallel.ForEachAsync(
Enumerable.Range(1, options.Iterations),
new ParallelOptions { MaxDegreeOfParallelism = options.Iterations },
async (iteration, cancellationToken) =>
{
await using var browserContext = await browser.NewContextAsync();
var page = await browserContext.NewPageAsync();
page.GotoAsync("https://localhost/");
page.ClickAsync("body > header > nav > button");
await Task.Delay(10000); // This is just for debugging purposes
}
);
Description
I have a Blazor Server App that is hosted in IIS. In this App, I have a Button (HTML) that has a Click handler () => NavigationManager.NavigateTo(url, true);
. All the handler does is navigate to a Login Page.
I wanted to test my Application with Playwright and it works OK when I start only 1-2 instances. When I try with more than 3 instances then it hangs as soon as the click page.ClickAsync("body > header > nav > button");
is executed. if I close some instances then other instances continue working as they should.
What I have noticed is that if the second parameter in NavigationManager.NavigateTo(url, true);
is set to false
then it works.
This can be reproduced with the default Blazor Server Template.
P.S.
If I just run the App with dotnet run
then it works!
Issue Analytics
- State:
- Created a year ago
- Comments:11 (6 by maintainers)
I’ve been experimenting with this since my last comment. It seems the issue is on the IIS side. I was using IIS on Windows Home and not on Windows Server and based on some online documentation, IIS on Windows Home has a limit on the number of concurrent connections.
I have created a virtual machine with Windows Server and I am not facing the same issue - I was able to execute 100 parallel tests.
Sorry if I bothered you and thanks a lot for your time.
Sorry for the late reply. I’m unfortunately not familiar with Blazor either but, happy to accept any PRs/research in that direction.