refactor(resources): share artifact cleanup errors with their leases (#14606)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-11-25 15:48:59 -05:00
1 parent bfa50774f5
commit b16df9d6c7
8 files changed
+49 -76

No files matched your search

@@ -11,9 +11,8 @@ import {
} from "../../domain/javascript/javascriptSemanticWorkAllowance.js";
import { MAX_NODE_TIMER_DELAY_MS } from "../../domain/analysisResourceLimits.js";
import {
artifactFileCleanupError,
ArtifactResourceScope,
ArtifactReaderFailure,
bindArtifactFileCleanup,
} from "../../resources/index.js";
import { analysisErrorWithCleanupDependencies } from "../../domain/analysisErrorCleanup.js";
import {
@@ -1443,16 +1442,8 @@ export class JavaScriptAnalysisWorker {
: cancellation.capturedOutput === undefined
? cancellation.retainCapturedOutput(this.#captured())
: cancellation;
if (cause instanceof ArtifactReaderFailure && cause.cleanup !== undefined) {
const error = new ProviderCleanupError(
PROVIDER,
cause.cleanup.resources,
{ reason: cause.cleanup.reason },
{ operation: OPERATION, cause },
);
bindArtifactFileCleanup(cause, error);
return error;
}
const fileCleanup = artifactFileCleanupError(cause, PROVIDER, OPERATION);
if (fileCleanup !== undefined) return fileCleanup;
if (
cause instanceof AnalysisError &&
(deadline === undefined || this.#phase === "startup")