-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Feature] External cancellation of ...WaitFor...
methods where feasible
#24083
Comments
Thanks for the feature request, unfortunately this is not compatible with the way Playwright, the driver and calls to the browser are working. If you sent once something to the browser, it can't be canceled. Since we don't plan on implementing this, I will close it for now. |
Could you take another look at this? |
Yup sorry for closing this before, re-opening by that. |
Could you provide a complete example where you benefit from the cancellation token? I'd like to understand the use case better. |
We discussed this feature in our team and came to the conclusion that this change might confuse users. While event handlers, aka. WaitFor* methods can be cancelled, the code you have inside, can not. Often these are clicks, evaluates, etc. To keep a clear boundary about this, we decided to not go forward with this API proposal. I apologise for being slow on this PRs/issues, since some of our coworkers were out of office. Thank you! |
But it's all about cancelling the wait/listen for event, not the action. There is no way for early cancel of any |
The code inside the callback still continues to run and does not follow .NET's rule of periodically checking if the cancellation was requested. This is a fundamental feature which Playwright does not offer and yield in unexpected behaviour. We recommend Task.WhenAny() instead. |
So more spaghetti code instead. :( |
Add external cancellation of
...WaitFor...
methods where feasible.Reasoning:
Wait for style methods have a timeout, but there are circumstances where external events could be the cause to cancel specific waits.
The current solution doesn't provide any cancellation except default/custom timouts.
The text was updated successfully, but these errors were encountered: