Skip to content

Conversation

@nvborisenko
Copy link

This PR make Playwright events waiter more friendly with sync-over-async pattern.

Issue

This piece of code demonstrates deadlock. Real code, you can run it (I ran it in NUnit).

await page.RunAndWaitForResponseAsync(async () =>
{
    await page.GotoAsync("https://linked.in");
}, new Regex(".*google.*"));

//await Task.Yield();

Task.Run(async () => await page.Locator(".nav__logo-link").ClickAsync()).GetAwaiter().GetResult();

Here GetAwaiter().GetResult() is blocked. We understand that it is anti-pattern, sync-over-async. To fix it we can add await Task.Yield(). But what if Playwright can be more friendly for dummy users like me?

Solution?

This PR allows tasks continuations asynchronously. Now the code above just works.

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 this pull request may close these issues.

1 participant