mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 06:04:03 +00:00
fix(reference): retain cancellation during policy file cleanup (#12323)
fix(reference): preserve cancellation during policy file cleanup
This commit is contained in:
1 parent
c5709b8697
commit
00e2346c2c
2 files changed
+65
-18
No files matched your search
@@ -162,42 +162,36 @@ const readPolicyFile = async (
|
||||
new IgnorePolicyReadCancelled(reason),
|
||||
});
|
||||
} catch (cause: unknown) {
|
||||
if (cause instanceof IgnorePolicyReadCancelled) throw cause;
|
||||
if (!(cause instanceof RegularFileCleanupFailure)) throw cause;
|
||||
const cancellation = regularFileCancellation(cause);
|
||||
const retry = await retryRegularFileCleanup(cause, resources, signal);
|
||||
const operationCancellation =
|
||||
cause.outcome.kind === "failed"
|
||||
? regularFileCancellation(cause)
|
||||
: undefined;
|
||||
const cancellationFailure =
|
||||
cancellation === undefined
|
||||
? undefined
|
||||
: new IgnorePolicyReadCancelled(cancellation.reason);
|
||||
if (retry.cleanup !== undefined) {
|
||||
const primary =
|
||||
retry.outcome.kind === "failed"
|
||||
cancellationFailure ??
|
||||
(retry.outcome.kind === "failed"
|
||||
? retry.outcome.cause
|
||||
: cause.cleanupCause;
|
||||
: cause.cleanupCause);
|
||||
const primaryCause = ignorePolicyCause(primary);
|
||||
return err({
|
||||
...failure(
|
||||
isIgnorePolicyCancellation(primary) ||
|
||||
operationCancellation !== undefined
|
||||
? "cancelled"
|
||||
: "io",
|
||||
isIgnorePolicyCancellation(primary) ? "cancelled" : "io",
|
||||
`Reference source ignore policy could not be read at ${policyPath}: ${errorMessage(primaryCause)}`,
|
||||
),
|
||||
cleanup: retry.cleanup,
|
||||
cause: primaryCause,
|
||||
...(signal !== undefined &&
|
||||
isAborted(signal) &&
|
||||
!isIgnorePolicyCancellation(primary) &&
|
||||
operationCancellation === undefined
|
||||
!isIgnorePolicyCancellation(primary)
|
||||
? { secondaryCancellation: { cause: signal.reason } }
|
||||
: {}),
|
||||
});
|
||||
}
|
||||
if (retry.outcome.kind === "failed") {
|
||||
if (operationCancellation !== undefined)
|
||||
throw new IgnorePolicyReadCancelled(operationCancellation.reason);
|
||||
throw retry.outcome.cause;
|
||||
}
|
||||
if (cancellationFailure !== undefined) throw cancellationFailure;
|
||||
if (retry.outcome.kind === "failed") throw retry.outcome.cause;
|
||||
text = retry.outcome.value;
|
||||
}
|
||||
return ok(text);
|
||||
|
||||
Reference in new issue
Block a user