Skip to content

Resolve #2755: Settle Studio sidecar on partial-body close#2761

Merged
ayden94 merged 1 commit into
mainfrom
issue-2755-settle-sidecar-partial-body-close
Jul 14, 2026
Merged

Resolve #2755: Settle Studio sidecar on partial-body close#2761
ayden94 merged 1 commit into
mainfrom
issue-2755-settle-sidecar-partial-body-close

Conversation

@ayden94

@ayden94 ayden94 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Studio sidecar ingestion could hang indefinitely when a local client closed the socket after sending only a partial request body. The readBody reader only listened for end and error events, so a partial-body close (where neither event fires) left the ingestion Promise pending forever, allowing a malformed local client to consume sidecar work without bound.

Linked context: Closes #2755

Changes

  • packages/cli/src/studio/sidecar.ts: readBody now binds the request close event to body-reader cancellation. A settled guard ensures only the first of end/error/close wins, and all listeners are removed once settled. close rejects with a descriptive bounded error distinguishing zero-body vs partial-body close.
  • packages/cli/src/studio/sidecar.ts: writeJson now guards against writing to an already-ended response, so the bounded error completion path does not throw when the client socket is already closed.
  • packages/cli/src/studio/sidecar.test.ts: Added two regression tests — one for partial-body close (client sends partial JSON then closes) and one for zero-body close (client sends headers only then closes). Both assert the sidecar does not accept the event and remains usable.
  • packages/cli/README.md / packages/cli/README.ko.md: Documented the partial-body close settlement invariant in the Studio sidecar security defaults section (EN/KO parity).
  • .changeset/studio-sidecar-partial-body-close.md: Patch changeset for @fluojs/cli (CLI-launched sidecar lifecycle is documented tooling behavior).

Testing

  • pnpm --filter @fluojs/cli test — 393 tests passed (13 files), including the 2 new partial-body close regression tests.
  • pnpm --filter @fluojs/cli typecheck — passed.
  • pnpm build — full monorepo build passed.

Release impact

  • This PR has consumer-visible release impact and includes a changeset.

The sidecar ingestion lifecycle is documented @fluojs/cli tooling behavior. A malformed local client could previously hang sidecar work indefinitely; this change settles ingestion with a bounded error completion. Patch bump is appropriate because no public API surface or documented ordering changes — only a latent hang is fixed.

Public export documentation

  • Changed public exports include a source-level summary.

No public exports changed. The readBody function is module-internal; the StudioSidecar public interface is unchanged.

Behavioral contract

  • No documented behavioral contracts were removed without migration notes.
  • New behavioral contracts are documented in the affected package README.
  • Intentional limitations are explicitly stated (not silently removed).
  • Runtime invariants are covered by regression tests.

The new invariant — "the sidecar settles ingestion requests with a bounded error completion when a local client closes the socket after sending only a partial request body" — is documented in packages/cli/README.md and packages/cli/README.ko.md, and covered by regression tests in packages/cli/src/studio/sidecar.test.ts.

Platform consistency governance (SSOT)

  • SSOT English/Korean mirror structure remains synchronized for changed governance docs.

The CLI README EN/KO pair was updated in lockstep. No platform contract docs or package-surface docs changed.

Bind request close/error events to body-reader cancellation so a
malformed local client that closes the socket after a partial request
body cannot hang sidecar ingestion indefinitely. The sidecar now sends
a bounded error completion instead of leaving the request pending.

- Add close handler to readBody that rejects with a descriptive error
- Guard writeJson against writing to an already-ended response
- Add regression tests for partial-body and zero-body close
- Document the lifecycle invariant in CLI README (EN/KO)
- Add patch changeset for @fluojs/cli
@ayden94
ayden94 merged commit a88152c into main Jul 14, 2026
19 of 20 checks passed
@ayden94
ayden94 deleted the issue-2755-settle-sidecar-partial-body-close branch July 14, 2026 01:37
This was referenced Jul 14, 2026
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.

[audit][area:cli] Settle Studio sidecar on partial-body close (priority:p1)

1 participant