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.

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 issue

Context:

  • 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:closed
  • Created a year ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dardanlibrarycommented, Jul 26, 2022

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.

0reactions
mxschmittcommented, Jul 23, 2022

Sorry for the late reply. I’m unfortunately not familiar with Blazor either but, happy to accept any PRs/research in that direction.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Playwright/Browsers hang when having more than ...
Playwright /Browsers hang when having more than 3 (sometimes 2) instances running at the same time when testing a Blazor Server App #2203....
Read more >
Isolation
This isolation model improves reproducibility and prevents cascading test failures. ... Running the test creates a new browser context each time.
Read more >
ASP.NET Core Blazor performance best practices
Tips for increasing performance in ASP.NET Core Blazor apps and avoiding common performance problems.
Read more >
Testing Blazor Applications with Playwright | .NET Conf 2022
" Testing is hard, testing takes time to learn and to write, and time is money. As developers we want to test. We...
Read more >
Blazor App Testing with Playwright - YouTube
ASP.NET Community Standup - Blazor App Testing with Playwright. 6.8K views · Streamed 5 months ago # Blazor # Playwright #dotnet ... more...
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