Skip to content

Commit

Permalink
Fix XRPC fetch usage for newly required duplex option (bluesky-social…
Browse files Browse the repository at this point in the history
…#470)

Fix xrpc fetch usage for newly required duplex option
  • Loading branch information
devinivy authored Jan 18, 2023
1 parent b718761 commit caef814
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/xrpc/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@ async function defaultFetchHandler(
httpReqBody: unknown,
): Promise<FetchHandlerResponse> {
try {
const res = await fetch(httpUri, {
// The duplex field is now required for streaming bodies, but not yet reflected
// anywhere in docs or types. See whatwg/fetch#1438, nodejs/node#46221.
const reqInit: RequestInit & { duplex: string } = {
method: httpMethod,
headers: httpHeaders,
body: encodeMethodCallBody(httpHeaders, httpReqBody),
})
duplex: 'half',
}
const res = await fetch(httpUri, reqInit)
const resBody = await res.arrayBuffer()
return {
status: res.status,
Expand Down

0 comments on commit caef814

Please sign in to comment.