perf(javascript): park the worker after preload-discovery allowance refusals

A scoped worker closed instead of parking after any failed analysis, so one member-mutation refusal during preload discovery discarded the process and every static checkpoint it retained. Discovery skips such a source and the normal pass analyzes and reports it again, and the worker reports the refusal while staying healthy. A discovery checkout whose failures are all member-mutation refusals now parks if canReuse still holds. Other failures, and any failure in a normal analysis, still close the worker.

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-23 23:40:19 +08:00
1 parent 5b280e1f9f
commit ef59a1f0a3
2 files changed
+100 -2

No files matched your search

@@ -1,4 +1,7 @@
import { DEFAULT_JAVASCRIPT_MEMBER_MUTATION_ALLOWANCE } from "../../domain/javascript/javascriptSemanticWorkAllowance.js";
import {
DEFAULT_JAVASCRIPT_MEMBER_MUTATION_ALLOWANCE,
isJavaScriptMemberMutationRefusal,
} from "../../domain/javascript/javascriptSemanticWorkAllowance.js";
import { resolveJavaScriptSemanticPrecision } from "../../domain/javascript/javascriptSemanticPrecision.js";
import type {
JavaScriptSourceAnalysisLimits,
@@ -179,8 +182,21 @@ class ScopeJavaScriptSourceAnalysis implements JavaScriptSourceAnalysisPort {
analyze(
...args: Parameters<JavaScriptSourceAnalysisPort["analyze"]>
): ReturnType<JavaScriptSourceAnalysisPort["analyze"]> {
const purpose = args[5];
return this.worker.analyze(...args).then((result) => {
if (!result.ok) this.#failed = true;
// Preload discovery skips a source whose member-mutation allowance the
// worker refused and reported; the normal pass recomputes and reports
// it. That refusal leaves the process healthy, so the worker can still
// park and keep the static checkpoints discovery retained. canReuse
// still checks the process before parking.
if (
!result.ok &&
!(
purpose === "preload-discovery" &&
isJavaScriptMemberMutationRefusal(result.error.error)
)
)
this.#failed = true;
return result;
});
}