microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.47k stars 235 forks source link

[Bug]: Closing The Browser Context Does Not Always Also Close All The Pages #1838

Closed Xen0byte closed 2 years ago

Xen0byte commented 2 years ago

Playwright version

1.17.0

Operating system

Windows

What browsers are you seeing the problem on?

Chromium

Other information

both .NET5 and .NET6

What happened? / Describe the bug

When I click a logout button that redirects to an identity provider (KeyCloak), that page does not close when I do await Context.CloseAsync(), and instead it hangs indefinitely. I have managed to work around the issue by adding foreach (IPage page in Context.Pages) await page.CloseAsync(); to my after feature hook (I'm using Specflow, but can reproduce this issue without it).

Code snippet to reproduce your bug

await logoutButton.ClickAsync();
await Page.WaitForURLAsync(url => url.Contains("openid-connect/auth"));
// this is where I get redirected to a "log back in" (via KeyCloak) page
await Context.CloseAsync();
// ...this used to work in v1.15.x
// but now I also need to do this for this single use case...
foreach (IPage page in Context.Pages) await page.CloseAsync();

Relevant log output

No response

fr4gles commented 2 years ago

Those issues might be related: https://github.com/microsoft/playwright-dotnet/issues/1749 https://github.com/microsoft/playwright-dotnet/issues/1815

Xen0byte commented 2 years ago

Those issues might be related: #1749 #1815

Aha, thanks for this! I did have a quick look through the issues before posting, but it did not occur to me that these might be related, however, upon reading the details, you might be right. I haven't inspected the process pool yet for zombies.

mxschmitt commented 2 years ago

Was able to reproduce and its fixed by https://github.com/microsoft/playwright-dotnet/pull/1864.