Skip to content

follow-up: comprehensive vendored Ceen CancellationToken audit (streaming, file, chunked-encoding sites) #258

Description

@ottobolyos

Context

Consolidation issue surfaced by the dime cycle 4-7 review sequence on PR #219.

Cycles 4-7 fixed the following CancellationToken-threading gaps in the vendored Ceen HTTP tree:

  • MTConnectPostResponseHandler.ReadRequestBytes (F-IMP-001, cycle 4)
  • SimpleProxyHandler.HandleAsync request-body drain (F-IMP-005, cycle 5)
  • RestApiHelper.Post / PutDetail body reads (F-IMP-005, cycle 5)
  • SimpleProxyHandler.HandleAsync response copy (F-IMP-C6-001, cycle 6)
  • WriteAllAsync(Stream) + WriteResponse + WriteToStream chain (F-IMP-C7-001, cycle 7)
  • HttpRequest.cs multipart form parser — tracked at follow-up: multipart form parser leaks read task on cancellation (Ceen HttpRequest) #257

Residual gaps

The following sites remain on tokenless overloads and warrant a batched follow-up rather than atomic in-scope work, either because they carry different lifetime semantics from the simple sibling pattern or because they are vendored code that is not exercised by MTConnect production paths.

  1. Streaming endpointsMTConnectHttpResponseHandler.WriteToResponseStream (libraries/MTConnect.NET-HTTP/Servers/MTConnectHttpResponseHandler.cs:214) via args.Message.CopyToAsync(responseStream) (tokenless). Reached from MTConnectCurrentResponseHandler + MTConnectSampleResponseHandler via event-delegate closures over HeartbeatReceived / DocumentReceived. The correct fix pattern here is not a simple 3-arg overload — the stream's lifetime is event-driven and the CT needs to compose with MTConnectHttpServerStream.Stop(). Bounded by socket-level failure surfacing through the delegate exception path, so behaviour is not immediately buggy — but a proper fix threads the outer cancellationToken from OnRequestReceived into the event-delegate closures.

  2. File-serving handlersFileHandler.cs:388, 665 and FileMirrorHandler.cs:263, 278, 510, 513 — all ReadAsync / WriteAsync sites on file-mirror or file-serve read loops. Vendored dead code (not exercised by MTConnect production paths); low priority; batch under this issue when convenient.

  3. Low-level chunked-encoding helpersHttpResponse.cs:368, 373, 403, 410, 488 — internal WriteAsync sites in the private chunk-header writes. Below the public API abstraction; a fix requires threading CT through the internal Send / FlushChunkAsync helpers, which is a wider refactor than the CA2022 warnings-cleanup scope.

Composes with

Provenance

Dime cycles 4-7 on PR #219, 2026-08-21. Filed per CONVENTIONS §1.0d-trigies-septies (MEDIUM+ findings must be CLOSED, SKIP-rationale, or TRACKED before Ready flip) as the aggregate TRACK for residual vendored-Ceen CT-threading work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions