refactor(binary): group session selection and snapshot ownership (#886)

This commit is contained in:
ysopwnable authored and GitHub committed 2026-10-07 15:05:29 +08:00
1 parent ab985c6a10
commit dd114d3980
59 files changed
+220 -190

No files matched your search

@@ -0,0 +1,29 @@
import { ProviderCleanupError } from "../../domain/providerCleanupError.js";
import { err, ok, type Result } from "../../domain/result.js";
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
import type { AnalysisClient, ExecutionOptions } from "../AnalysisProvider.js";
/** Close one provider client and normalize unexpected adapter rejection. */
export const closeAnalysisClient = async (
client: AnalysisClient,
providerId: string,
options: Pick<ExecutionOptions, "progress"> & {
readonly retainDocument?: boolean;
} = {},
): Promise<Result<null, AnalysisError>> => {
try {
if (client.closeWithOutcome !== undefined)
return await client.closeWithOutcome(options);
await client.close();
return ok(null);
} catch (cause: unknown) {
return err(
new ProviderCleanupError(
providerId,
["provider-client"],
{ reason: "provider client close rejected unexpectedly" },
{ cause },
),
);
}
};