mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 10:04:50 +00:00
perf(javascript): keep the worker reusable after a final discovery refusal
The worker's reuse state cleared its last failure only on success, so a member-mutation refusal of the last discovered source still closed the worker and discarded every retained static checkpoint. The worker now owns the recoverable-refusal rule, and the scope uses the same predicate. Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
1 parent
ef59a1f0a3
commit
c2779ae514
3 files changed
+48
-37
No files matched your search
@@ -5,6 +5,7 @@ import {
|
||||
import {
|
||||
DEFAULT_JAVASCRIPT_MEMBER_MUTATION_ALLOWANCE,
|
||||
javaScriptMemberMutationAllowanceField,
|
||||
isJavaScriptMemberMutationRefusal,
|
||||
javaScriptMemberMutationRefusal,
|
||||
reportsJavaScriptMemberMutationRefusal,
|
||||
} from "../../domain/javascript/javascriptSemanticWorkAllowance.js";
|
||||
@@ -140,6 +141,20 @@ type WorkerPrimaryFailure =
|
||||
};
|
||||
|
||||
/** One sequential owned worker, retained between source files and closed after analysis. */
|
||||
/**
|
||||
* 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 it does not block reuse and the
|
||||
* static checkpoints discovery retained survive.
|
||||
*/
|
||||
export const isRecoverableJavaScriptWorkerFailure = (
|
||||
purpose: "analysis" | "preload-discovery",
|
||||
result: Result<JavaScriptAnalyzedSource, JavaScriptSourceAnalysisFailure>,
|
||||
): boolean =>
|
||||
purpose === "preload-discovery" &&
|
||||
!result.ok &&
|
||||
isJavaScriptMemberMutationRefusal(result.error.error);
|
||||
|
||||
export class JavaScriptAnalysisWorker {
|
||||
readonly #runId = `rea-javascript-analysis-${randomUUID()}`;
|
||||
readonly #runtime: OwnedWorkerRuntime;
|
||||
@@ -623,7 +638,8 @@ export class JavaScriptAnalysisWorker {
|
||||
if (this.#deadline === deadline) this.#deadline = undefined;
|
||||
if (this.#activeJobId === id) this.#activeJobId = undefined;
|
||||
}
|
||||
if (result.ok) this.#lastFailure = undefined;
|
||||
if (result.ok || isRecoverableJavaScriptWorkerFailure(purpose, result))
|
||||
this.#lastFailure = undefined;
|
||||
else if (!(result.error.error instanceof ProviderCleanupError))
|
||||
this.#lastFailure = result.error.error;
|
||||
// Child stop must be verified before temporary files are released. On
|
||||
|
||||
Reference in new issue
Block a user