Skip to content

Commit 9336f76

Browse files
chore: add comment about the reasoning behind duplex (#2367)
1 parent 193a786 commit 9336f76

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/server/auth-client.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ ca/T0LLtgmbMmxSv/MmzIg==
204204
// Connect Account
205205
if (url.pathname === "/me/v1/connected-accounts/connect") {
206206
if (onConnectAccountRequest) {
207-
// When body is send, new Request() requires duplex: 'half'
208-
// This appeared to only become neccessary once we started using the fetcher.
207+
// Connect Account uses a fetcher for DPoP.
208+
// This means it creates a `new Request()` internally.
209+
// When a body is sent as an object (`{ foo: 'bar' }`), it will be exposed as a `ReadableStream` below.
210+
// When a `ReadableStream` is used as body for a `new Request()`, setting `duplex: 'half'` is required.
211+
// https://github.com/whatwg/fetch/pull/1457
209212
await onConnectAccountRequest(
210213
new Request(input, { ...init, duplex: "half" } as RequestInit)
211214
);
@@ -228,8 +231,11 @@ ca/T0LLtgmbMmxSv/MmzIg==
228231
// Connect Account complete
229232
if (url.pathname === "/me/v1/connected-accounts/complete") {
230233
if (onCompleteConnectAccountRequest) {
231-
// When body is send, new Request() requires duplex: 'half'
232-
// This appeared to only become neccessary once we started using the fetcher.
234+
// Complete Connect Account uses a fetcher for DPoP.
235+
// This means it creates a `new Request()` internally.
236+
// When a body is sent as an object (`{ foo: 'bar' }`), it will be exposed as a `ReadableStream` below.
237+
// When a `ReadableStream` is used as body for a `new Request()`, setting `duplex: 'half'` is required.
238+
// https://github.com/whatwg/fetch/pull/1457
233239
await onCompleteConnectAccountRequest(
234240
new Request(input, { ...init, duplex: "half" } as RequestInit)
235241
);

0 commit comments

Comments
 (0)