Resolve #2755: Settle Studio sidecar on partial-body close#2761
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Studio sidecar ingestion could hang indefinitely when a local client closed the socket after sending only a partial request body. The
readBodyreader only listened forendanderrorevents, 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:readBodynow binds the requestcloseevent to body-reader cancellation. Asettledguard ensures only the first ofend/error/closewins, and all listeners are removed once settled.closerejects with a descriptive bounded error distinguishing zero-body vs partial-body close.packages/cli/src/studio/sidecar.ts:writeJsonnow 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
The sidecar ingestion lifecycle is documented
@fluojs/clitooling 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
No public exports changed. The
readBodyfunction is module-internal; theStudioSidecarpublic interface is unchanged.Behavioral contract
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.mdandpackages/cli/README.ko.md, and covered by regression tests inpackages/cli/src/studio/sidecar.test.ts.Platform consistency governance (SSOT)
The CLI README EN/KO pair was updated in lockstep. No platform contract docs or package-surface docs changed.