Support HttpApiSchema.StreamUint8Array request payloads in HttpApiClient#6505
Support HttpApiSchema.StreamUint8Array request payloads in HttpApiClient#6505leonitousconforti wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: f3eccc3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughThis change preserves ChangesStreaming request payloads
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/effect/src/unstable/httpapi/HttpApiClient.ts`:
- Around line 1003-1016: Update the stream-schema handling around
HttpApiSchema.isStreamUint8Array so StreamUint8Array and StreamSse encoders are
not cached or retrieved by shared AST identity. Key bodyFromPayloadCache by the
schema object for stream schemas, or bypass that cache for them, ensuring each
schema preserves its own contentType and mode; add a regression test covering
distinct custom content types.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 2cbb97b2-3731-4daf-b828-316c164acc27
📒 Files selected for processing (4)
.changeset/httpapi-client-stream-request-payloads.mdpackages/effect/src/unstable/httpapi/HttpApiClient.tspackages/effect/src/unstable/httpapi/HttpApiEndpoint.tspackages/effect/test/unstable/httpapi/HttpApiClient.test.ts
| if (HttpApiSchema.isStreamUint8Array(schema)) { | ||
| const out = $HttpBody.pipe(Schema.decodeTo( | ||
| schema, | ||
| SchemaTransformation.transformOrFail<Stream.Stream<Uint8Array, unknown>, HttpBody.HttpBody>({ | ||
| decode(httpBody) { | ||
| return Effect.fail(new SchemaIssue.Forbidden(Option.some(httpBody), { message: "Encode only schema" })) | ||
| }, | ||
| encode(stream) { | ||
| return Effect.succeed(HttpBody.stream(stream, schema.contentType)) | ||
| } | ||
| }) | ||
| )) | ||
| bodyFromPayloadCache.set(ast, out) | ||
| return out |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Do not cache stream encoders by the shared AST.
StreamUint8Array and StreamSse instances share streamSchema.ast, but their contentType and mode live on the schema object. Because the AST cache is checked before this branch, the first stream schema can determine the encoder for later requests, causing custom content types to be silently wrong or bypassing this branch entirely.
Use a cache keyed by schema identity, or skip bodyFromPayloadCache for stream schemas. Add a regression test with a custom content type.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/effect/src/unstable/httpapi/HttpApiClient.ts` around lines 1003 -
1016, Update the stream-schema handling around HttpApiSchema.isStreamUint8Array
so StreamUint8Array and StreamSse encoders are not cached or retrieved by shared
AST identity. Key bodyFromPayloadCache by the schema object for stream schemas,
or bypass that cache for them, ensuring each schema preserves its own
contentType and mode; add a regression test covering distinct custom content
types.
Bundle Size Analysis
|
Type
Description
Related
Summary by CodeRabbit
Bug Fixes
Tests
Documentation