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:
John Dvorak
2026-05-22 12:00:20 -07:00
parent a424d29ccc
commit e17e4d6c20
3 changed files with 22 additions and 14 deletions
@@ -726,7 +726,9 @@ export async function extractWorldFastGeometry(
for (const el of nodes) {
el.removeAttribute('data-imhotep-runtime-id')
}
}).catch(() => {})
}).catch((err) => {
console.debug('[imhotep-playwright] fast-geometry cleanup evaluate failed:', err instanceof Error ? err.message : err)
})
}
}
@@ -910,7 +912,9 @@ export async function extractWorldCdp(
for (const el of nodes) {
el.removeAttribute('data-imhotep-runtime-id')
}
}).catch(() => {})
}).catch((err) => {
console.debug('[imhotep-playwright] CDP cleanup evaluate failed:', err instanceof Error ? err.message : err)
})
await sessionManager.detach()
}
}
@@ -940,7 +944,8 @@ export async function extractWorld(
width: Number.isFinite(measured?.width) ? Number(measured.width) : 0,
height: Number.isFinite(measured?.height) ? Number(measured.height) : 0,
}
} catch {
} catch (err) {
console.warn(`[imhotep-playwright] resolveViewport: page.evaluate failed (${err instanceof Error ? err.message : err}), falling back to 0x0 viewport`)
return { width: 0, height: 0 }
}
}