mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 06:04:03 +00:00
refactor(process): compose supervision and provider-client cleanup failures through the shared owner (#10905)
* refactor(process): compose supervision and provider-client cleanup failures through the shared owner * refactor(native): compose LLDB, native UI and signature cleanup failures through the shared owner (#10908) * refactor(native): compose LLDB, native UI and signature cleanup failures through the shared owner * refactor(server): compose close, reset and session-status cleanup failures through the shared owner (#10915) * refactor(dotnet): compose managed snapshot cleanup failures through the shared owner (#10917) * refactor(dotnet): compose managed snapshot cleanup failures through the shared owner * refactor(flutter): compose build cleanup failures through the shared owner (#10918) * refactor(flutter): compose build cleanup failures through the shared owner * refactor(apple): compose asset catalog and keyed archive cleanup failures through the shared owner (#10919) * refactor(ghidra): join session cleanup failures through the shared owner (#10920) * refactor(ghidra): join session cleanup failures through the shared owner * refactor(desktop): compose build-setup cleanup failures through the shared owner (#10921) * refactor(desktop): compose build-setup cleanup failures through the shared owner * refactor(cutter): compose bridge service cleanup failures through the shared owner (#10922) * refactor(cutter): compose bridge service cleanup failures through the shared owner * refactor(electron): compose fuse and file-scope cleanup failures through the shared owner (#10923) * refactor(electron): compose fuse and file-scope cleanup failures through the shared owner * refactor(browser): compose scenario, web-bundle and capture cleanup failures through the shared owner (#10924) * refactor(application): compose uninstall, session retirement and decompile-all cleanup failures through the shared owner (#10933) * refactor(application): compose uninstall, session retirement and decompile-all cleanup failures through the shared owner * refactor(ghidra): compose Java probe, NativeAOT snapshot and provider-client cleanup failures through the shared owner (#10927) * refactor(ghidra): compose Java probe, NativeAOT snapshot and provider-client cleanup failures through the shared owner * refactor(hopper): compose provider close cleanup failures through the shared owner (#10928) * refactor(hopper): compose provider close cleanup failures through the shared owner * refactor(javascript): compose analysis worker runtime and inspection failures through the shared owner (#10929) * refactor(javascript): compose analysis worker runtime and inspection failures through the shared owner * refactor(kuna): compose project-cache and target-command cleanup failures through the shared owner (#10930) * refactor(kuna): compose project-cache and target-command cleanup failures through the shared owner * refactor(native): compose macOS provider, pwndbg and pwntools cleanup failures through the shared owner (#10931) * refactor(native): compose macOS provider, pwndbg and pwntools cleanup failures through the shared owner * refactor(wasm): compose WABT artifact cleanup failures through the shared owner (#10932) * refactor(wasm): compose WABT artifact cleanup failures through the shared owner * refactor(application): compose analysis-view cancellation and retained-content cleanup failures through the shared owner (#10941) * refactor(application): compose analysis-view cancellation and retained-content cleanup failures through the shared owner * refactor(kuna): compose span-close cancellation cleanup through the shared owner (#10942) * refactor(decompile): bind the initialization failure with its cleanup through the shared owner (#10965) * refactor(decompile): bind the initialization failure with its cleanup through the shared owner * refactor(cli): bind environment serve listener and close failures through the shared owner (#10966) * refactor(cli): bind environment serve listener and close failures through the shared owner * refactor(kuna): bind project export and span-read failures with their cleanup through the shared owner (#10967) * refactor(kuna): bind project export and span-read failures with their cleanup through the shared owner * refactor(cutter): bind descriptor read failures with their cleanup through the shared owner (#10968) * refactor(cutter): bind descriptor read failures with their cleanup through the shared owner * refactor(ida): bind workspace file failures with their cleanup through the shared owner (#10969) * refactor(ida): bind workspace file failures with their cleanup through the shared owner * refactor(rizin): bind debug finalization failures with their cleanup through the shared owner (#10970) * refactor(rizin): bind debug finalization failures with their cleanup through the shared owner * refactor(application): compose close rejections with unknown completion through one owner (#10971) * refactor(application): compose close rejections with unknown completion through one owner * refactor(hopper): compose startup and launcher close rejections through the shared owner (#10972) * refactor(hopper): compose startup and launcher close rejections through the shared owner * refactor(desktop): compose task-file close rejections through the shared owner (#10973) * fix(hopper): confirm reported close failures when a later close of the client succeeds * fix(hopper): keep owned close failures reading their own owner on retry HopperClient bound every failed close part to its client retry, so a launcher aggregate that already follows its child failures stayed pending after the launcher released them. AnalysisCleanupRelease.bindUnowned now owns the rule that a retry claims only ownerless failures; BinarySession's local copy of it is removed. * fix(hopper): release each close part's earlier failures when that part succeeds One shared retry release made the session part's earlier failures wait for the launcher part too, so a later close whose session cleanup succeeded kept reporting the session's released resources. HopperClient keeps one release per part (session, launcher), and each part confirms its own failures when it succeeds.
This commit is contained in:
1 parent
21adb649ac
commit
cd1b35bcb9
78 files changed
+554
-440
No files matched your search
@@ -80,7 +80,12 @@ import {
|
||||
prepareSessionExecution,
|
||||
} from "./BinarySessionExecution.js";
|
||||
import { closeAnalysisClient } from "../../providers/AnalysisClientCleanup.js";
|
||||
import { analysisErrorWithCleanupFailure } from "../../domain/analysisErrorCleanup.js";
|
||||
import {
|
||||
analysisErrorWithCleanupFailure,
|
||||
analysisErrorWithCleanupDependencies,
|
||||
analysisErrorWithCloseRejection,
|
||||
analysisErrorWithCloseRejections,
|
||||
} from "../../domain/analysisErrorCleanup.js";
|
||||
import { ConfigurationError } from "../../domain/configurationErrors.js";
|
||||
import type { AnalysisCleanupRetry } from "../../domain/analysisErrorRecovery.js";
|
||||
import { analysisErrorWithCancellation } from "../../domain/analysisErrorCancellation.js";
|
||||
@@ -118,30 +123,6 @@ interface CleanupFailureTracker {
|
||||
readonly onFailure: (failure: AnalysisError) => void;
|
||||
}
|
||||
|
||||
/** Compose live cleanup facts without treating an unowned rejection as completion. */
|
||||
const sessionCleanupFailure = (
|
||||
primary: AnalysisError,
|
||||
cleanup: AnalysisError,
|
||||
operation: string,
|
||||
): AnalysisError => {
|
||||
const failure = analysisErrorWithCleanupFailure(primary, cleanup, operation);
|
||||
return cleanup.cleanupIncomplete
|
||||
? failure.bindCleanupDependencies([primary, cleanup])
|
||||
: failure;
|
||||
};
|
||||
|
||||
/**
|
||||
* Let a cleanup failure the client's close reported read that close. A failure
|
||||
* whose cleanup already follows its own owner keeps reading that owner.
|
||||
*/
|
||||
const bindClientRelease = (
|
||||
release: AnalysisCleanupRelease,
|
||||
failure: AnalysisError,
|
||||
): void => {
|
||||
if (failure.cleanupIncomplete && !failure.hasCleanupOwner)
|
||||
release.bind(failure);
|
||||
};
|
||||
|
||||
const trackCleanupFailures = (
|
||||
signal: AbortSignal | undefined,
|
||||
operation: string,
|
||||
@@ -168,14 +149,20 @@ const trackCleanupFailures = (
|
||||
} else {
|
||||
// Both operands are cleanup observations here. An earlier rejection
|
||||
// without a live lifecycle must not disappear when a later owner resolves.
|
||||
cleanupFailure = cleanupFailure.cleanupIncomplete
|
||||
? sessionCleanupFailure(cleanupFailure, failure, operation)
|
||||
: analysisErrorWithCleanupFailure(cleanupFailure, failure, operation);
|
||||
cleanupFailure = analysisErrorWithCloseRejections(
|
||||
cleanupFailure,
|
||||
failure,
|
||||
operation,
|
||||
);
|
||||
}
|
||||
error =
|
||||
cancellation === undefined
|
||||
? cleanupFailure
|
||||
: sessionCleanupFailure(cancellation, cleanupFailure, operation);
|
||||
: analysisErrorWithCloseRejection(
|
||||
cancellation,
|
||||
cleanupFailure,
|
||||
operation,
|
||||
);
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -303,7 +290,7 @@ export class BinarySession
|
||||
return err(
|
||||
closed.ok
|
||||
? started.error
|
||||
: sessionCleanupFailure(
|
||||
: analysisErrorWithCloseRejection(
|
||||
started.error,
|
||||
closed.error,
|
||||
"open_bundle_resources",
|
||||
@@ -317,7 +304,7 @@ export class BinarySession
|
||||
return err(
|
||||
closed.ok
|
||||
? cancelled
|
||||
: sessionCleanupFailure(
|
||||
: analysisErrorWithCloseRejection(
|
||||
cancelled,
|
||||
closed.error,
|
||||
"open_bundle_resources",
|
||||
@@ -340,7 +327,7 @@ export class BinarySession
|
||||
cleanupFailures.error ??
|
||||
(candidateClosed.ok
|
||||
? primary
|
||||
: analysisErrorWithCleanupFailure(
|
||||
: analysisErrorWithCloseRejections(
|
||||
primary,
|
||||
candidateClosed.error,
|
||||
"open_bundle_resources",
|
||||
@@ -358,7 +345,7 @@ export class BinarySession
|
||||
cleanupFailures.error ??
|
||||
(candidateClosed.ok
|
||||
? cancelled
|
||||
: sessionCleanupFailure(
|
||||
: analysisErrorWithCloseRejection(
|
||||
cancelled,
|
||||
candidateClosed.error,
|
||||
"open_bundle_resources",
|
||||
@@ -855,11 +842,11 @@ export class BinarySession
|
||||
const primary = completionFailure(value, retired.error);
|
||||
const failure =
|
||||
retired.error.cleanupIncomplete && primary !== retired.error
|
||||
? analysisErrorWithCleanupFailure(
|
||||
? analysisErrorWithCleanupDependencies(
|
||||
primary,
|
||||
retired.error,
|
||||
operationName,
|
||||
).bindCleanupDependencies([primary, retired.error])
|
||||
)
|
||||
: primary;
|
||||
return err(
|
||||
isAborted(signal)
|
||||
@@ -1136,24 +1123,20 @@ export class BinarySession
|
||||
let resourceFailure = resourceFailures[0];
|
||||
for (const next of resourceFailures.slice(1))
|
||||
if (resourceFailure !== undefined) {
|
||||
const previous = resourceFailure;
|
||||
resourceFailure = analysisErrorWithCleanupFailure(
|
||||
previous,
|
||||
resourceFailure = analysisErrorWithCloseRejections(
|
||||
resourceFailure,
|
||||
next,
|
||||
"close_binary",
|
||||
);
|
||||
if (previous.cleanupIncomplete && next.cleanupIncomplete)
|
||||
resourceFailure.bindCleanupDependencies([previous, next]);
|
||||
}
|
||||
if (!closed.ok && resourceFailure !== undefined) {
|
||||
const combined = analysisErrorWithCleanupFailure(
|
||||
closed.error,
|
||||
resourceFailure,
|
||||
"close_binary",
|
||||
return err(
|
||||
analysisErrorWithCloseRejections(
|
||||
closed.error,
|
||||
resourceFailure,
|
||||
"close_binary",
|
||||
),
|
||||
);
|
||||
if (closed.error.cleanupIncomplete && resourceFailure.cleanupIncomplete)
|
||||
combined.bindCleanupDependencies([closed.error, resourceFailure]);
|
||||
return err(combined);
|
||||
}
|
||||
if (!closed.ok) return closed;
|
||||
return resourceFailure === undefined ? ok(null) : err(resourceFailure);
|
||||
@@ -1178,20 +1161,14 @@ export class BinarySession
|
||||
);
|
||||
if (!closed.ok) {
|
||||
retained.push(session);
|
||||
const previous = failure;
|
||||
failure =
|
||||
previous === undefined
|
||||
failure === undefined
|
||||
? closed.error
|
||||
: analysisErrorWithCleanupFailure(
|
||||
previous,
|
||||
: analysisErrorWithCloseRejections(
|
||||
failure,
|
||||
closed.error,
|
||||
"close_binary",
|
||||
);
|
||||
if (
|
||||
previous?.cleanupIncomplete === true &&
|
||||
closed.error.cleanupIncomplete
|
||||
)
|
||||
failure.bindCleanupDependencies([previous, closed.error]);
|
||||
}
|
||||
}
|
||||
this.#pendingBundleResourceCleanup = retained;
|
||||
@@ -1235,7 +1212,7 @@ export class BinarySession
|
||||
...(progress === undefined ? {} : { progress }),
|
||||
...(pending.retainDocument ? { retainDocument: true } : {}),
|
||||
onCleanupFailure: (failure) => {
|
||||
bindClientRelease(pending.release, failure);
|
||||
pending.release.bindUnowned(failure);
|
||||
onCleanupFailure?.(failure);
|
||||
},
|
||||
},
|
||||
@@ -1243,7 +1220,7 @@ export class BinarySession
|
||||
if (closed.ok) {
|
||||
pending.release.confirm();
|
||||
this.#pendingCleanup = undefined;
|
||||
} else bindClientRelease(pending.release, closed.error);
|
||||
} else pending.release.bindUnowned(closed.error);
|
||||
return closed;
|
||||
}
|
||||
|
||||
@@ -1258,7 +1235,11 @@ export class BinarySession
|
||||
onCleanupFailure === undefined ? {} : { onCleanupFailure },
|
||||
);
|
||||
if (!closed.ok)
|
||||
return sessionCleanupFailure(primary, closed.error, "open_binary");
|
||||
return analysisErrorWithCloseRejection(
|
||||
primary,
|
||||
closed.error,
|
||||
"open_binary",
|
||||
);
|
||||
return this.#restoreAfterFailedOpen(previous, primary);
|
||||
}
|
||||
|
||||
@@ -1274,7 +1255,7 @@ export class BinarySession
|
||||
),
|
||||
});
|
||||
return restored.error.cleanupIncomplete
|
||||
? sessionCleanupFailure(primary, restored.error, "open_binary")
|
||||
? analysisErrorWithCloseRejection(primary, restored.error, "open_binary")
|
||||
: primary;
|
||||
}
|
||||
|
||||
@@ -1780,7 +1761,13 @@ export class BinarySession
|
||||
const closed = await this.#retireClient(run);
|
||||
return closed.ok
|
||||
? err(started.error)
|
||||
: err(sessionCleanupFailure(started.error, closed.error, "open_binary"));
|
||||
: err(
|
||||
analysisErrorWithCloseRejection(
|
||||
started.error,
|
||||
closed.error,
|
||||
"open_binary",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async #waitForTransition(
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
CapabilityDescriptor,
|
||||
} from "../../ports/AnalysisProvider.js";
|
||||
import { AnalysisCapabilityUnavailableError } from "../../domain/analysisErrorCore.js";
|
||||
import { analysisErrorWithCleanupFailure } from "../../domain/analysisErrorCleanup.js";
|
||||
import { analysisErrorWithCloseRejections } from "../../domain/analysisErrorCleanup.js";
|
||||
import { err, ok } from "../../domain/result.js";
|
||||
import type { ResolvedAppBundleResourceRoot } from "../../domain/apple/bundleResourceRoot.js";
|
||||
import { closeAnalysisClient } from "../../providers/AnalysisClientCleanup.js";
|
||||
@@ -78,14 +78,13 @@ export const combineBundleResourceClients = (
|
||||
closeAnalysisClient(nativeClient, "bundle-resources", options),
|
||||
]);
|
||||
if (!artifact.ok && !native.ok) {
|
||||
const failure = analysisErrorWithCleanupFailure(
|
||||
artifact.error,
|
||||
native.error,
|
||||
"close_binary",
|
||||
return err(
|
||||
analysisErrorWithCloseRejections(
|
||||
artifact.error,
|
||||
native.error,
|
||||
"close_binary",
|
||||
),
|
||||
);
|
||||
if (artifact.error.cleanupIncomplete && native.error.cleanupIncomplete)
|
||||
failure.bindCleanupDependencies([artifact.error, native.error]);
|
||||
return err(failure);
|
||||
}
|
||||
if (!artifact.ok) return artifact;
|
||||
if (!native.ok) return native;
|
||||
|
||||
Reference in new issue
Block a user