fix(desktop): keep every state-reader close failure in the cleanup composite

The desktop state-reader close collects up to three failures (artifact
scope, SQLite service, and the export worker retry), but composed only
the first two with analysisErrorWithCleanupFailure and bound the rest by
hand. The third failure's reason never reached the caller. Fold the
failures through analysisErrorWithCleanupDependencies so each keeps its
reason and owner; two failures produce the same composite as before.

Refs #11859

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
gensokyo-devandgensokyo-dev authored and Ysopwnable committed 2026-11-21 19:07:31 +01:00
1 parent a80dc68318
commit 10597e10f2
3 files changed
+195 -8

No files matched your search

+4 -7
View File
@@ -10,7 +10,7 @@ import type { Logger } from "pino";
import { captureDesktopApplication } from "../application/desktop/DesktopApplicationCapture.js";
import type { DesktopStateReaders } from "../application/desktop/DesktopApplicationState.js";
import { AnalysisError } from "../domain/analysisErrorBase.js";
import { analysisErrorWithCleanupFailure } from "../domain/analysisErrorCleanup.js";
import { analysisErrorWithCleanupDependencies } from "../domain/analysisErrorCleanup.js";
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
import {
ArtifactReaderFailure,
@@ -256,13 +256,10 @@ const withStateReaders = async (
bindArtifactFileCleanup(cause, failure);
return failure;
});
const combined = analysisErrorWithCleanupFailure(
typed[0]!,
typed[1]!,
operation,
// Fold left so every close failure keeps its reason and owner.
throw typed.reduce((primary, cleanup) =>
analysisErrorWithCleanupDependencies(primary, cleanup, operation),
);
combined.bindCleanupDependencies(typed);
throw combined;
}
},
},