From caef814b0f25994904d9cc18586083228d74e5f4 Mon Sep 17 00:00:00 2001 From: devin ivy Date: Wed, 18 Jan 2023 17:18:35 -0500 Subject: [PATCH] Fix XRPC fetch usage for newly required duplex option (#470) Fix xrpc fetch usage for newly required duplex option --- packages/xrpc/src/client.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/xrpc/src/client.ts b/packages/xrpc/src/client.ts index fe6c7fd537b..b8cafc30921 100644 --- a/packages/xrpc/src/client.ts +++ b/packages/xrpc/src/client.ts @@ -137,11 +137,15 @@ async function defaultFetchHandler( httpReqBody: unknown, ): Promise { 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,