mirror of
https://github.com/morluto/rea.git
synced 2026-10-28 10:25:42 +00:00
* 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>
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
/** 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);
|
|
}
|
|
};
|