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.

[Feature]: Provide ability to pass CancellationToken into Async methods

See original GitHub issue

Is there a way to use cancellation tokens to cancel async operations?

It would be helpful to have most of the async methods able to be cancelled. Especially methods like

await page.GotoAsync("https://github.com/");

which would then be:

await page.GotoAsync("https://github.com/", cancellationToken);

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:11
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
schrufygroovycommented, Nov 25, 2022

@mxschmitt this is true from a browser user perspective, but I think it’s really not about cancelling any actions/commands but more about cancelling potential waiting process for the callbacks of the commands.

As far as I can see all commands are sent via SendMessageToServerAsync() - and for each command the callback is being awaited. Why should it not be reasonable to cancel this instead of waiting for callback to be fulfilled? For example when I want to cancel the execution (e.g: some test run, or some executable), why would I still need to wait until the await page.GotoAsync("https://github.com/") command is having some callback. I just want the execution to be stopped gracefully as fast as possible and no “hanging” execution.

I would really appreciate, if you would reconsider your decision or give us some alternative way to gracefully cancel pending commands.

2reactions
avodovnikcommented, Jul 8, 2022

Hi! Thanks for the suggestion. This is definitely something to consider. For now, I’ve marked it as collecting feedback, and we’ll go from there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Associate a CancellationToken with an async method's Task
Run , you'll get a canceled task that raises TaskCanceledException when await ed, but if you cancel a token passed to Task.Run after...
Read more >
Recommended patterns for CancellationToken
Know when you've passed the point of no cancellation. · Propagate your CancellationToken to all the methods you call that accept one, except ......
Read more >
Patterns & Practices for efficiently handling C# async/await ...
The simplest pattern for cancellation processing is to provide a CancellationToken at the end of the argument and propagate it to the inner ......
Read more >
Cancelling await calls in .NET 6 with Task.WaitAsync()
In this post I discuss the new Task.WaitAsync() APIs introduced in .NET 6 and how you can use them to cancel an await...
Read more >
Cancellation with Async F#, C# and the Reactive Extensions
The problem here is pretty simple: the cancellation token only cancels the task created by Task.Run(). This can be problematic, particularly if ...
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