fix(apktool): resolve Windows PATH launchers before invocation (#2802)

* fix(apktool): resolve Windows PATH launchers before invocation

Resolve the default launcher through the selected PATH/PATHEXT before choosing native process creation or the existing conservative cmd.exe wrapper. Reuse the resulting selection and one canonical environment for the version probe and decode.

Follow-up to the release #1693 review of #1777. Source inspected and formatted; tests, builds, check reruns and real Windows Apktool execution were skipped at maintainer request.

* fix(apktool): bound lookup and retain only selected environment

Source inspection and targeted formatting only. Tests, builds, lint, typechecks and provider workloads were not run at the user's explicit request.

* fix(apktool): use supported timeout diagnostics

Retain lookup phase through AnalysisErrorOptions diagnostics while preserving the operation and timeout identity. Source inspection and targeted formatting only; tests, checks, builds and provider workloads were skipped at the user request.

---------

Co-authored-by: morluto <morluto@users.noreply.github.com>
This commit is contained in:
morluto
2026-10-13 22:00:47 +08:00
committed by GitHub
co-authored by morluto
parent ae9a7f34e1
commit 1eca600515
9 changed files with 486 additions and 55 deletions
@@ -1,29 +0,0 @@
/** Sentinel returned when an abort signal wins an asynchronous race. */
export const ABORTED = Symbol("aborted");
/**
* Await a promise without depending on the producer to observe cancellation.
* The producer still receives its signal separately and remains responsible for
* releasing any resources that it owns.
*/
export const waitForAbortable = async <Value>(
pending: Promise<Value>,
signal: AbortSignal | undefined,
): Promise<Value | typeof ABORTED> => {
if (signal === undefined) return pending;
let onAbort: (() => void) | undefined;
const cancelled = new Promise<typeof ABORTED>((resolve) => {
if (signal.aborted) {
resolve(ABORTED);
return;
}
onAbort = () => resolve(ABORTED);
signal.addEventListener("abort", onAbort, { once: true });
});
try {
// Even an already-cancelled wait must own the producer's eventual rejection.
return await Promise.race([cancelled, pending]);
} finally {
if (onAbort !== undefined) signal.removeEventListener("abort", onAbort);
}
};
@@ -12,7 +12,7 @@ import { jsonObjectSchema, type JsonValue } from "../../domain/jsonValue.js";
import { err, ok, type Result } from "../../domain/result.js";
import type { AnalysisProviderCandidate } from "../AnalysisProvider.js";
import type { AnalysisProviderCandidateStatus } from "./AnalysisProviderRegistry.js";
import { ABORTED, waitForAbortable } from "./AbortablePromise.js";
import { ABORTED, waitForAbortable } from "../../process/AbortablePromise.js";
/** Profile-resolution truth for one discovered provider candidate. */
export interface AnalysisProviderCandidateEvaluation {
@@ -5,7 +5,7 @@ import { AnalysisError } from "../../domain/analysisErrorBase.js";
import { ProviderAdapterError } from "../../domain/providerAdapterError.js";
import type { ProviderOperationHealth } from "../../domain/providerOperationHealth.js";
import { err, ok } from "../../domain/result.js";
import { ABORTED, waitForAbortable } from "./AbortablePromise.js";
import { ABORTED, waitForAbortable } from "../../process/AbortablePromise.js";
import type {
AnalysisClient,
AnalysisClientContext,