Skip to content

The container's cloud-prefetch page payloads pin a whole page each #253

Closed

Description

@nc9

buildCloudPagePayloads in packages/audit-engine/src/cloud-prefetch-run.ts keeps a textExcerpt per page:

textExcerpt: truncateUtf8Bytes(parsed.content.textContent, MAX_EXCERPT_BYTES),

truncateUtf8Bytes returns text.slice(0, maxBytes) unchanged whenever the sliced text already fits the byte budget, which is every all-ASCII page. In JSC a retained slice pins the buffer it was cut from, so each 6 KB excerpt holds its page's entire HTML as UTF-16 for as long as the payload list lives. That list lives across the whole streamed pre-rules walk, which is exactly the walk that exists to stop holding pages.

The same applies to title, the meta.description slice, and each heading in headings, and to the URL and selector sets absorbBlocklistUrls / absorbBlocklistSelectors retain and the seeds absorbSeeds retains. Those three are capped (1,500 urls, 500 selectors, 50 seeds) so the worst case is bounded by the cap rather than by page count, but the page payloads are one per page.

It shows only in process.memoryUsage().external, not in heapUsed and not in RSS, which is why it survives a casual look. See #240 for the same class of bug in the external-link collector.

The CLI's twin of this code was fixed in #252 by wrapping the retained payload in detachFromPage(..., "cloud-payload") and detaching the url/selector/seed entries at the point of retention. The container-side replica here still has it.

Acceptance Criteria

  • buildCloudPagePayloads in packages/audit-engine/src/cloud-prefetch-run.ts retains no string that references the page it was read off
  • The blocklist url and selector sets and the gaps seeds retain detached strings
  • The prefetch request body is unchanged: same fields, same values, same order
  • Measured on a per-page-distinct fixture of ~1 MB pages, process.memoryUsage().external after the collection walk no longer scales with page count

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions