microsoft / microsoft/playwright-dotnet

[Feature]: IAPIRequestContext.GetAsync should be cancellable

Open
#3,218 0 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P3-collecting-feedback
Dominant language
C#
Stars
3k
Forks
304
Avg merge
20h 47m
Merged PRs (30d)
6

Description

🚀 Feature Request

The API doesn't support CancellationToken anywhere. In issue #1652 it was explained that cancellation would be pointless in many UI-based cases.

However there are cases where it would be actually useful, and expected according to .NET standards.

For example: page.APIRequest.GetAsync. That initiates a network call and should definitely be cancellable.

Example
await page.APIRequest.GetAsync("https://www.example.com/foo", cancellationToken);
Motivation

A network call that cannot be cancelled is not standard .NET and surprising.

Notes

If the method uses HttpClient "under the hood", then one should simply provide it with the cancellation token. It probably that simple.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at IAPIRequestContext.GetAsync and trace the API request implementation to identify where the network call is made and how cancellation can be passed through. Check the existing request API and its tests for conventions around overloads and cancellation. Done means the example call accepts a CancellationToken and an in-flight request can be cancelled.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.