Azure / Azure/azure-iot-sdk-csharp
[Bug Report] RegistryManager.CreateQuery does not support cancellation tokens
- Dominant language
- C#
- Stars
- 477
- Forks
- 492
- Avg merge
- 9h 55m
- Merged PRs (30d)
- 2
Description
# Context
- **OS, version, SKU and CPU architecture used:** Windows 11 Desktop x64,
- **Application's .NET Target Framework :** net8.0
- **Device:** N/A
- **SDK version used:** Microsoft.Azure.Devices 1.40
## Description of the issue
The RegistryManager.CreateQuery does not contain an input for a cancellation token. It seems like the code inside it just passed `CancellationToken.None` into all internal calls
## Code sample exhibiting the issue
From `Microsoft.Azure.Devices.RegistryManager`
```csharp
public virtual IQuery CreateQuery(string sqlQueryString, int? pageSize)
{
if (Logging.IsEnabled)
{
Logging.Enter(this, $"Creating query", "CreateQuery");
}
try
{
return new Query((string token) => ExecuteQueryAsync(sqlQueryString, pageSize, token, CancellationToken.None)); // <--- This
}
catch (Exception ex)
{
if (Logging.IsEnabled)
{
Logging.Error(this, FormattableStringFactory.Create("{0} threw an exception: {1}", "CreateQuery", ex), "CreateQuery");
}
throw;
}
finally
{
if (Logging.IsEnabled)
{
Logging.Exit(this, $"Creating query", "CreateQuery");
}
}
}
```
## Console log of the issue
N/A
Contributor guide
Research direction
Start at Microsoft.Azure.Devices.RegistryManager.CreateQuery and trace its call to ExecuteQueryAsync, including the Query callback shown in the report. Determine how a caller-provided cancellation token should flow through the query API and its internal calls. Done means query cancellation is accepted and propagated instead of using CancellationToken.None.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100