Skip to content

fix(cluster): snapshot mutable binary source chunks #894

Description

@tomdps

Parent

Problem

The runtime-portable readBoundedSource implementation retains caller-owned Uint8Array views until iteration completes. An async source may reuse or mutate a yielded backing buffer before the reader assembles the payload, overwriting earlier bytes and producing malformed or semantically different JSON.

Scope

  • Snapshot every caller-owned binary chunk before requesting the next async-iterator item. String chunks produced by the reader remain owned and need no redundant copy.
  • Preserve the exact byte ceiling, strict UTF-8/JSON behavior, abort behavior, Buffer-free runtime portability, and existing ClusterRequestError contracts.
  • Add a regression test whose async source reuses and mutates one backing Uint8Array across yields; assert the originally yielded bytes are decoded.
  • Cover a subarray/shared-backing-buffer case so retaining a view cannot regress.
  • Avoid unrelated changes and do not modify the known unrelated E2E cleanup-race tests.

Delivery

Target the existing PR #891 head branch through a dependent PR whose base is zeroshot/platinum-forest-30. Parent PR #891 remains paused until this fix lands and all required checks pass.

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