fix(cancellation): bind retained errors to cleanup owners

Carry the capture handle cleanup lease through retry results and bind composed export failures to it. Bind aborted binary retirement errors to the failed close so successful later cleanup reveals the original cancellation.

Validation: 46 focused tests passed; npm run check passed. Four regression assertions fail on the original source. Full suite and real-provider workflows were not run.
This commit is contained in:
morluto committed 2026-10-22 04:17:14 +08:00
1 parent 087813fb88
commit a721c42c07
5 files changed
+88 -31

No files matched your search

+3
View File
@@ -16,6 +16,7 @@ import {
type RegularFileOperationOutcome,
} from "../filesystem/OwnedRegularFile.js";
import { readBoundedFileBytes } from "../process/BoundedFileBytes.js";
import type { AnalysisCleanupLease } from "../artifacts/AnalysisCleanupLease.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import type { AnalysisCleanupObservation } from "../domain/analysisErrorBase.js";
@@ -62,6 +63,7 @@ export const retryRegularFileCleanup = async <Value>(
signal?: AbortSignal,
): Promise<{
readonly outcome: RegularFileReadOutcome<Value>;
readonly cleanupLease?: AnalysisCleanupLease;
readonly cleanup?: AnalysisCleanupObservation;
}> => {
const outcome: RegularFileReadOutcome<Value> =
@@ -79,6 +81,7 @@ export const retryRegularFileCleanup = async <Value>(
if (released.kind === "released") return { outcome };
return {
outcome,
cleanupLease: released.lease,
cleanup: {
reason: `${failureMessage(failure.cleanupCause)}; retry: ${failureMessage(released.cause)}`,
resources: [failure.path],