mirror of
https://github.com/morluto/rea.git
synced 2026-11-08 07:46:28 +00:00
Refs #4458, #4483. Own admitted descriptors through final close, retain exact failed owners, and preserve physical read failures and cancellation reasons. Track stream coverage independently from delivered bytes and share the boundary across archive, Mach-O, hashing, and output readback consumers.
29 lines
921 B
TypeScript
29 lines
921 B
TypeScript
import { expect, it } from "vitest";
|
|
import { ArtifactReaderFailure } from "./ArtifactReader.js";
|
|
|
|
it.each([
|
|
undefined,
|
|
null,
|
|
"caller reason",
|
|
new ArtifactReaderFailure("cancelled", "caller-provided error"),
|
|
])(
|
|
"preserves explicit cancellation through repeated cleanup composition: %s",
|
|
(reason) => {
|
|
const primary = new ArtifactReaderFailure("cancelled", "Read cancelled", {
|
|
cause: reason,
|
|
});
|
|
const first = ArtifactReaderFailure.withCleanup(primary, {
|
|
reason: "first close failed",
|
|
resources: ["first"],
|
|
});
|
|
const second = ArtifactReaderFailure.withCleanup(first, {
|
|
reason: "second close failed",
|
|
resources: ["second"],
|
|
});
|
|
expect(second.cancellation).toBe(primary.cancellation);
|
|
expect(second.cancellation?.reason).toBe(reason);
|
|
expect(second.cleanup?.resources).toEqual(["first", "second"]);
|
|
expect(second.cause).toBe(first);
|
|
},
|
|
);
|