Skip to content

Commit

Permalink
fix ClientRequest stream bodies (#1959)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Jan 22, 2024
1 parent 202befc commit fe05ad7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-baboons-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/platform": patch
---

fix ClientRequest stream bodies
9 changes: 4 additions & 5 deletions packages/platform/src/Http/ClientRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type * as PlatformError from "../Error.js"
import type * as FileSystem from "../FileSystem.js"
import * as internal from "../internal/http/clientRequest.js"
import type * as Body from "./Body.js"
import type * as Error from "./ClientError.js"
import type * as Headers from "./Headers.js"
import type { Method } from "./Method.js"
import type * as UrlParams from "./UrlParams.js"
Expand Down Expand Up @@ -332,13 +331,13 @@ export const formDataBody: {
*/
export const streamBody: {
(
body: Stream.Stream<never, Error.RequestError, Uint8Array>,
options?: { readonly contentType?: string; readonly contentLength?: number }
body: Stream.Stream<never, unknown, Uint8Array>,
options?: { readonly contentType?: string | undefined; readonly contentLength?: number | undefined } | undefined
): (self: ClientRequest) => ClientRequest
(
self: ClientRequest,
body: Stream.Stream<never, Error.RequestError, Uint8Array>,
options?: { readonly contentType?: string; readonly contentLength?: number }
body: Stream.Stream<never, unknown, Uint8Array>,
options?: { readonly contentType?: string | undefined; readonly contentLength?: number | undefined } | undefined
): ClientRequest
} = internal.streamBody

Expand Down
3 changes: 2 additions & 1 deletion packages/platform/src/internal/http/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ export const fetch = (options?: RequestInit): Client.Client.Default =>
method: request.method,
headers,
body,
duplex: request.body._tag === "Stream" ? "half" : undefined,
signal
}),
} as any),
catch: (_) =>
internalError.requestError({
request,
Expand Down
5 changes: 2 additions & 3 deletions packages/platform/src/internal/http/clientRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type * as Stream from "effect/Stream"
import type * as PlatformError from "../../Error.js"
import type * as FileSystem from "../../FileSystem.js"
import type * as Body from "../../Http/Body.js"
import type * as Error from "../../Http/ClientError.js"
import type * as ClientRequest from "../../Http/ClientRequest.js"
import * as Headers from "../../Http/Headers.js"
import type { Method } from "../../Http/Method.js"
Expand Down Expand Up @@ -398,15 +397,15 @@ export const formDataBody = dual<
/** @internal */
export const streamBody = dual<
(
body: Stream.Stream<never, Error.RequestError, Uint8Array>,
body: Stream.Stream<never, unknown, Uint8Array>,
options?: {
readonly contentType?: string
readonly contentLength?: number
}
) => (self: ClientRequest.ClientRequest) => ClientRequest.ClientRequest,
(
self: ClientRequest.ClientRequest,
body: Stream.Stream<never, Error.RequestError, Uint8Array>,
body: Stream.Stream<never, unknown, Uint8Array>,
options?: {
readonly contentType?: string
readonly contentLength?: number
Expand Down

0 comments on commit fe05ad7

Please sign in to comment.