mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 05:32:44 +00:00
refactor(process): inherit cleanup ownership for debugger cancellation (#12537)
This commit is contained in:
3 files changed
+34
-4
No files matched your search
@@ -33,7 +33,6 @@
|
||||
"src/pcap/PcapProvider.ts": 5,
|
||||
"src/pcap/PcapSnapshot.ts": 1,
|
||||
"src/process/ArtifactAnalysisResources.ts": 1,
|
||||
"src/process/OwnedDebuggerSessionRegistry.ts": 1,
|
||||
"src/process/capture/ProcessCaptureError.ts": 3,
|
||||
"src/providers/AnalysisClientFailure.ts": 1,
|
||||
"src/sqlite/SqliteDatabaseProvider.ts": 8
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { AnalysisCancelledError } from "../domain/analysisErrorCore.js";
|
||||
import { cancelledWithCallerReason } from "./OwnedDebuggerSessionRegistry.js";
|
||||
|
||||
it("preserves the caller's reason while a retained cancellation waits for release", () => {
|
||||
const reason = new Error("caller stopped waiting");
|
||||
const previous = new AnalysisCancelledError("start", {
|
||||
cleanup: {
|
||||
reason: "session still closing",
|
||||
resources: ["session"],
|
||||
},
|
||||
});
|
||||
const claim = { cleanupReleased: false };
|
||||
previous.bindCleanupReleaseClaim(claim);
|
||||
const current = cancelledWithCallerReason(
|
||||
"close",
|
||||
AbortSignal.abort(reason),
|
||||
previous,
|
||||
);
|
||||
expect(current.cause).toBe(reason);
|
||||
expect(current.cleanupPrimary).toBe(previous);
|
||||
expect(current.cleanupIncomplete).toBe(true);
|
||||
expect(current.cleanupResources).toEqual(["session"]);
|
||||
claim.cleanupReleased = true;
|
||||
expect(current.cleanupIncomplete).toBe(false);
|
||||
expect(
|
||||
cancelledWithCallerReason("close", AbortSignal.abort(reason))
|
||||
.cleanupIncomplete,
|
||||
).toBe(false);
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
import { withInheritedCleanupOwnership } from "../domain/analysisErrorCleanup.js";
|
||||
import type {
|
||||
AnalysisError,
|
||||
AnalysisErrorOptions,
|
||||
@@ -294,7 +295,7 @@ export const cancelledWithCallerReason = (
|
||||
? {}
|
||||
: { partialObservation: previous.partialObservation }),
|
||||
});
|
||||
if (previous?.cleanupIncomplete)
|
||||
cancellation.bindCleanupDependencies([previous]);
|
||||
return cancellation;
|
||||
return previous === undefined
|
||||
? cancellation
|
||||
: withInheritedCleanupOwnership(cancellation, previous);
|
||||
};
|
||||
Reference in new issue
Block a user