-
Notifications
You must be signed in to change notification settings - Fork 293
Run continuation asynchronously in context of events #3256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Apologies for the inquiry, but after a month without activity, I'm concerned I may have done something improperly. @mxschmitt, if you happen to know the cause, I would be very grateful for a hint. Thank you. |
|
Hi Nikolay, sorry for not taking a look earlier. I'll ask our colleague Dima for a review, but it'll take a little longer due to holidays. |
Skn0tt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some digging on the ramifications of this options, and it seems like a safe change for us. The only negative implication is a slight overhead since the continuation now needs to wait for the scheduler, but that microsecond impact is neglegible given we're dealing with slow browsers.
My understanding of DotNet's async scheduling is limited, so please take another look @dgozman.
|
It is absolutely safe, moreover it is recommended for libraries to prevent deadlocks I demonstrated in the original issue. |
dgozman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good to me. Let's add a test though, to avoid regressing this behavior.
|
Honestly, I am not sure how to test it properly. Please advise. |
Add a test next to this one that follows your repro code from this issue. I'd recommend to use this test page, so that you can wait for |
|
@microsoft-github-policy-service agree |
|
Added test, verified locally - it blocks in |
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).
Here
GetAwaiter().GetResult()is blocked. We understand that it is anti-pattern,sync-over-async. To fix it we can addawait 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.