mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
refactor(application): build application cancellations with a required reason (#10574)
* refactor(application): build application cancellations with a required reason Migrate every AnalysisCancelledError construction under src/application to cancelledBy and lower the guard baseline from 671 to 442. Shutdown refusals in BinarySession report OwnerCancellation.ownerClosed when the caller did not abort, instead of an undefined reason. ReverseEngineeringService and DesktopBuildOwnedWork close their work with the typed owner reason. SharedStartupAttempt returns the departing caller's reason with a cancelled wait. One shared isAborted predicate replaces eleven local copies and narrows a checked signal for cancelledBy. * refactor(desktop): drop an unused cancellation import from desktop capture state
This commit is contained in:
1 parent
0ddc732c69
commit
2826592759
86 files changed
+554
-1012
No files matched your search
@@ -7,7 +7,7 @@ import {
|
||||
type HistoricalSourceGraph,
|
||||
} from "../../domain/referenceSourceGraph.js";
|
||||
import type { ArtifactResourceScope } from "../../artifacts/ArtifactResourceScope.js";
|
||||
import { AnalysisCancelledError } from "../../domain/analysisErrorCore.js";
|
||||
import { cancelledBy, isAborted } from "../../domain/analysisErrorCore.js";
|
||||
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||
import { analysisInputErrorFromIssues } from "../../domain/inputIssueProjection.js";
|
||||
import { err, ok, type Result } from "../../domain/result.js";
|
||||
@@ -29,13 +29,8 @@ export const resolveSourceToBundleReference = async (
|
||||
signal?: AbortSignal,
|
||||
resources?: ArtifactResourceScope,
|
||||
): Promise<Result<ResolvedSourceToBundleReference, AnalysisError>> => {
|
||||
const cancelled = () => signal?.aborted === true;
|
||||
if (cancelled())
|
||||
return err(
|
||||
new AnalysisCancelledError("compare_source_to_bundle", {
|
||||
cause: signal?.reason,
|
||||
}),
|
||||
);
|
||||
if (isAborted(signal))
|
||||
return err(cancelledBy("compare_source_to_bundle", signal));
|
||||
if (!("kind" in reference)) return ok({ reference });
|
||||
const read = await readJsonFileWithSource(
|
||||
reference.path,
|
||||
@@ -45,12 +40,8 @@ export const resolveSourceToBundleReference = async (
|
||||
);
|
||||
if (!read.ok) return read;
|
||||
await setImmediate();
|
||||
if (cancelled())
|
||||
return err(
|
||||
new AnalysisCancelledError("compare_source_to_bundle", {
|
||||
cause: signal?.reason,
|
||||
}),
|
||||
);
|
||||
if (isAborted(signal))
|
||||
return err(cancelledBy("compare_source_to_bundle", signal));
|
||||
const headroom = requireAuthenticationHeadroom(read.value.data, {
|
||||
operation: "compare_source_to_bundle",
|
||||
path: read.value.path,
|
||||
@@ -61,12 +52,8 @@ export const resolveSourceToBundleReference = async (
|
||||
const parsed = historicalSourceGraphSchema.safeParse(read.value.data);
|
||||
// Dispatch aborts queued while synchronous validation and commitment hashing ran.
|
||||
await setImmediate();
|
||||
if (cancelled())
|
||||
return err(
|
||||
new AnalysisCancelledError("compare_source_to_bundle", {
|
||||
cause: signal?.reason,
|
||||
}),
|
||||
);
|
||||
if (isAborted(signal))
|
||||
return err(cancelledBy("compare_source_to_bundle", signal));
|
||||
if (!parsed.success)
|
||||
return err(
|
||||
analysisInputErrorFromIssues(
|
||||
|
||||
Reference in new issue
Block a user