Skip to content

PartDiscovery.CreatePartsAsync should throw OperationCanceledException when its cancellationToken parameter is canceled #620

@AArnott

Description

@AArnott

There are multiple overloads of PartDiscovery.CreatePartsAsync, that may use CreateAssemblyDiscoveryBlockChain or CreateDiscoveryBlockChain. Evidently, these chain-building methods' use of CancellationToken is not reliable, and it seems cancellation will abort the dataflow but may still return a 'successful' result, causing an incomplete collection of parts to be returned, and potentially an incomplete cache to be written, corrupting this and future sessions.

We should make sure the CancellationToken is set for every dataflow block that we create.
We should also verify (through automated testing and debugger inspection) that if cancellation aborts a dataflow, that an exception will propagate. If we cannot guarantee that, we should add a cancellationToken.ThrowIfCancellationRequested(); call at the end of each of the CreatePartsAsync methods.

Let's take both approaches: ensure CancellationToken is set for all dataflow blocks, and throw explicitly at the end of each of the public methods based on cancellation.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions