mirror of
https://github.com/morluto/rea.git
synced 2026-11-12 01:41:21 +00:00
fix(cancellation): preserve caller abort reason in cancellation errors (#6144)
* fix(cancellation): preserve caller abort reason in cancellation errors Several application, provider, and MCP boundaries constructed AnalysisCancelledError, ArtifactReaderFailure, or DetachedPgpSignatureError for an already-observed or newly-observed abort without passing the caller's signal.reason as the error cause. The typed result then reported cancellation with an undefined reason even though the exact object supplied to AbortController.abort(reason) was still available. Pass signal.reason as the cause at each producing cancellation site: JavaScript artifact reconstruction and file abort checks, derived MCP operation checkpoints, detached PGP verification, ASAR listing admission, Dart AOT inspection and its provider guard, evidence-file analysis views, binary layout and recorded crash admission, WASM inspection admission, and the Kuna shared assembly-index wait. Cancellation classification and cleanup behavior are unchanged. Fixes morluto/rea#5935 Fixes morluto/rea#5944 Fixes morluto/rea#6100 Fixes morluto/rea#6101 Fixes morluto/rea#6110 Fixes morluto/rea#6113 Fixes morluto/rea#6121 Fixes morluto/rea#6131 Fixes morluto/rea#6132 * test(cancellation): assert the exact caller reason identity Copied reasons satisfied toMatchObject, so the tests would pass even if the caller's abort reason were replaced by a structurally equal copy. Capture the rejection and assert the cause is the same object. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35b247e9-c793-4b8f-979a-807c27112cf5 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35b247e9-c793-4b8f-979a-807c27112cf5
This commit is contained in:
1 parent
7ffae5a791
commit
4e28166626
22 files changed
+253
-52
No files matched your search
@@ -1023,27 +1023,32 @@ describe("inspectAnalysisViewWithFiles", () => {
|
||||
|
||||
it("returns typed cancellation for a cancelled file request", async () => {
|
||||
const controller = new AbortController();
|
||||
controller.abort();
|
||||
const reason = Object.freeze({ requested: "view-stop" });
|
||||
controller.abort(reason);
|
||||
const parent = analysisViewCaptureEvidence(
|
||||
environmentManifestCaptureFixture(),
|
||||
);
|
||||
expect(
|
||||
await inspectAnalysisViewWithFiles(
|
||||
{
|
||||
source: {
|
||||
kind: "evidence-file",
|
||||
path: await writeEvidenceFile(parent),
|
||||
},
|
||||
view,
|
||||
const result = await inspectAnalysisViewWithFiles(
|
||||
{
|
||||
source: {
|
||||
kind: "evidence-file",
|
||||
path: await writeEvidenceFile(parent),
|
||||
},
|
||||
undefined,
|
||||
{ signal: controller.signal },
|
||||
),
|
||||
).toMatchObject({ ok: false, error: { _tag: "AnalysisCancelledError" } });
|
||||
view,
|
||||
},
|
||||
undefined,
|
||||
{ signal: controller.signal },
|
||||
);
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: { _tag: "AnalysisCancelledError" },
|
||||
});
|
||||
expect(result.ok ? undefined : result.error.cause).toBe(reason);
|
||||
});
|
||||
|
||||
it("returns typed cancellation when a running file request is aborted", async () => {
|
||||
const controller = new AbortController();
|
||||
const reason = Object.freeze({ requested: "running-view-stop" });
|
||||
const parent = analysisViewCaptureEvidence(
|
||||
environmentManifestCaptureFixture(),
|
||||
);
|
||||
@@ -1054,11 +1059,13 @@ describe("inspectAnalysisViewWithFiles", () => {
|
||||
{ signal: controller.signal },
|
||||
);
|
||||
// Queued before the request yields after its synchronous work, so it is seen even if the read already finished.
|
||||
setImmediate(() => controller.abort());
|
||||
expect(await running).toMatchObject({
|
||||
setImmediate(() => controller.abort(reason));
|
||||
const result = await running;
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: { _tag: "AnalysisCancelledError" },
|
||||
});
|
||||
expect(result.ok ? undefined : result.error.cause).toBe(reason);
|
||||
});
|
||||
|
||||
it("leaves file sources to the file-aware entry point", () => {
|
||||
|
||||
Reference in new issue
Block a user