fix: remove silent error suppression — cache failures, box index mutation, cleanup catches
geometry-cache.ts: replace 5 empty catch blocks with console.warn
- statSync failure, rmSync failure (x2), readCachedWorld failure,
readCachedExtractionResult failure were all silently swallowed.
Now emit context-bearing warnings so stale/corrupt caches are visible.
predicates.ts: replace __boxIndex as any mutation with WeakMap
- getBorderRect used (world as any).__boxIndex to cache a subject-to-
box-index map on the world object. Replaced with module-level WeakMap
that auto-collects when the world is GC'd. Eliminates 2 as any casts.
extraction.ts: serialize materializeSemanticSelector + debug cleanup
- 3 Promise.all sites over page.evaluate changed to sequential for..of
to eliminate DOM modification race conditions.
- 2 .catch(()=>{}) cleanup blocks now use console.debug so failed
cleanup is traceable when debugging.
- resolveViewport catch now emits console.warn on zero-viewport fallback.
648 SDK + 57 E2E tests pass.
This commit is contained in:
@@ -166,17 +166,17 @@ export function getRequiredFactsForPredicate(name: string): string[] {
|
||||
// Built-in Predicate Evaluators
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const boxIndexCache = new WeakMap<GeometryWorld, Map<number, number>>()
|
||||
|
||||
function getBorderRect(world: GeometryWorld, subjectId: number) {
|
||||
const { boxes } = world;
|
||||
// Build a subjectId -> boxIndex map on first use for O(1) lookups.
|
||||
// This avoids O(n) linear scans on every predicate evaluation.
|
||||
let index = (world as any).__boxIndex as Map<number, number> | undefined;
|
||||
let index = boxIndexCache.get(world);
|
||||
if (!index) {
|
||||
index = new Map<number, number>();
|
||||
for (let i = 0; i < boxes.subjectId.length; i++) {
|
||||
index.set(boxes.subjectId[i], i);
|
||||
}
|
||||
(world as any).__boxIndex = index;
|
||||
boxIndexCache.set(world, index);
|
||||
}
|
||||
const i = index.get(subjectId);
|
||||
if (i === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user