Skip to content

fix(sdk): bound SSE frames and scan fragmented lines once - #4501

Merged
ScriptedAlchemy merged 4 commits into
masterfrom
fix/sdk-bounded-sse-framing
Oct 24, 2026
Merged

ScriptedAlchemy merged 4 commits into
masterfrom
fix/sdk-bounded-sse-framing

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Problem

The TypeScript client accumulated SSE lines and frame fields without a byte ceiling, and rescanned an unfinished line from its beginning after every transport chunk. A fragmented line could therefore cause quadratic delimiter scanning; an oversized response could retain unbounded parser state.

Changes

  • Apply the Rust SDK's existing 64 KiB raw-line and retained event/ID/data policy, including line endings and data separators.
  • Scan each incoming byte once into a fixed line buffer. Large transport chunks are handled incrementally without decoding or copying the whole chunk.
  • Preserve streaming UTF-8, split CRLF, initial-only BOM handling and persistent last-event-ID accounting.
  • Refuse overflow with TraceDecayMalformedResponseError and payload.limitBytes. The existing response owner cancels the body; overflow cannot reconnect, deliver the oversized frame or mask its failure with a cleanup error.
  • Add a shared nine-case Rust/TypeScript framing corpus plus public-client tests for disposal, boundary conditions and deterministic linear byte inspection.
  • Regenerate the extension's embedded server with its owning build script. Its app bundle and generated SDK contracts are unchanged.

The current server's bounded identifiers, test-result names, frontiers, progress and terminal receipts fit this existing allowance. PRs #4487 and #4489 cover separate JSON-body and cursor-delivery behavior; their unmerged changes are not included here.

Validation

  • Before the fix: all 64 existing TypeScript SDK tests passed; nine new overflow checks failed and five compatibility checks passed.
  • After the fix: 82/82 TypeScript SDK tests passed, including 18 new framing checks.
  • SDK typecheck, package/declaration build and package dry run passed.
  • Extension build, embedded artifact check and 41 unit checks passed.
  • Pinned Rust formatting, commitlint and git diff --check passed.
  • 24/24 Rust SDK client tests passed via Cargo, including the shared nine-case framing corpus and existing overflow, near-limit, terminal, reconnect and cancellation checks.
  • Installed-package daemon conformance and 16 extension daemon integration cases could not start because this environment has no production tracedecay executable. These are not claimed as passing.

Fixes #4411.

@changeset-bot

changeset-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d942d80

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy
ScriptedAlchemy enabled auto-merge (squash) October 24, 2026 09:00
@ScriptedAlchemy
ScriptedAlchemy force-pushed the fix/sdk-bounded-sse-framing branch from 9e913bf to 18c8bde Compare October 24, 2026 09:41
ScriptedAlchemy and others added 3 commits October 24, 2026 15:06
Bound raw lines and retained event fields to the existing Rust SDK policy.
Scan transport bytes once through a fixed line buffer, preserving UTF-8,
CRLF and persistent IDs while refusing overflow before further reads.

Add shared Rust/TypeScript framing fixtures and public-client regression
checks, and regenerate the embedded extension server through its owner.

Fixes #4411.
@ScriptedAlchemy
ScriptedAlchemy force-pushed the fix/sdk-bounded-sse-framing branch from 831b1ab to f1d2bd8 Compare October 24, 2026 15:07
@ScriptedAlchemy
ScriptedAlchemy enabled auto-merge (squash) October 24, 2026 17:42
@ScriptedAlchemy
ScriptedAlchemy merged commit 1d7e794 into master Oct 24, 2026
18 checks passed
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.

fix(sdk): bound TypeScript SSE accumulation and stop rescanning unfinished lines

1 participant