Skip to content

fix(hyperfly): measure bytes by their real length, and keep caught errors coded - #94

Open
eliahilse wants to merge 1 commit into
mainfrom
fix/bytes-real-length
Open

eliahilse wants to merge 1 commit into
mainfrom
fix/bytes-real-length

Conversation

@eliahilse

Copy link
Copy Markdown
Owner

What

Two robustness fixes in the TS encoder, deferred from #85 and #66.

  • Bytes are measured by their real length.
    • A Uint8Array subclass that overrides length, byteLength, byteOffset, buffer, subarray or set could desync the length prefix from the bytes written.
    • The row encoder, both columnar sites and packed columns now read lengths and copy through the intrinsic %TypedArray% getters, so what they measure is what they write. This also works for subclasses from another realm.
    • The former test.todo now passes.
  • Only coded errors escape.
    • A Proxy around a real HyperflyError whose code getter revokes the proxy could escape the options and profile checks as a native TypeError.
    • Errors the library creates are now recognized by a trap-free brand, so caught user values are never inspected through their traps.

Performance

Bun 1.4.2, 100k rows with a 16-byte field, medians of 21 interleaved runs.

plan main this PR throughput
row 29.07 ms 25.27 ms +15%
columnar 14.99 ms 12.93 ms +16%

Tests

New cases cover each overridden accessor and method on the row, columnar and packed paths, a cross-realm subclass, length boundaries, and a revoking error proxy. Gates: lint, check-types, and bun test with 1480 passing and 0 failing. The changeset check is ok.

🤖 Generated with Claude Code

Co-Authored-By: GPT 6.1 Sol <noreply@openai.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant