mirror of
https://github.com/morluto/rea
synced 2026-10-25 22:08:11 -04:00
72ba1cd92b
Own operation results and exact rejections in withVerifierCleanup, including undefined, null and independent cleanup failures. Remove the optional-primary cleanup contract and migrate every caller, preserving returns, annotations, signal restoration and dependent cleanup order. Make Frida/JEB reporters fail on reasonless rejections and retain JEB fixture files while provider cleanup is incomplete. Own the nested packaged WASM verifier and expose its composite process/root cleanup capability for retry. Update runnable docs and isolated fixture dependencies. Validation: 547 focused cases in 20 files, eight isolated boundary unit checks, static/build/docs/discovery gates and duplication check (3.58%). Node process, SDK and descriptor cleanup are exercised; provider and packaging results in orchestration tests are simulated. Pack/install subprocess ownership remains with the existing shared package runner outside the nested-command change.
39 lines
1008 B
JavaScript
39 lines
1008 B
JavaScript
async function collectCleanupFailures(tasks) {
|
|
const failures = [];
|
|
for (const task of tasks) {
|
|
try {
|
|
await task();
|
|
} catch (cause) {
|
|
failures.push(cause);
|
|
}
|
|
}
|
|
|
|
return failures;
|
|
}
|
|
|
|
/** Attempt every independent cleanup and preserve each failure. */
|
|
export async function closeVerifierResources(tasks) {
|
|
const failures = await collectCleanupFailures(tasks);
|
|
if (failures.length > 0)
|
|
throw new AggregateError(failures, "Verifier cleanup failed");
|
|
}
|
|
|
|
/** Finish one operation and its cleanup without losing either failure. */
|
|
export async function withVerifierCleanup(operation, cleanupTasks) {
|
|
let value;
|
|
try {
|
|
value = await operation();
|
|
} catch (cause) {
|
|
const failures = await collectCleanupFailures(cleanupTasks);
|
|
if (failures.length > 0)
|
|
throw new AggregateError(
|
|
[cause, ...failures],
|
|
"Verifier cleanup failed",
|
|
{ cause },
|
|
);
|
|
throw cause;
|
|
}
|
|
await closeVerifierResources(cleanupTasks);
|
|
return value;
|
|
}
|