Skip to content

Commit e93052e

Browse files
committed
Recognize Bun and Deno streaming request support
1 parent 4948e70 commit e93052e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎packages/effect/src/http/FetchHttpClient.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,17 @@ let supportsStreamBody: boolean | undefined
8484
const detectStreamBodySupport = () => {
8585
try {
8686
let duplexAccessed = false
87+
const body = new ReadableStream()
8788
const request = new Request("https://example.com", {
8889
method: "POST",
89-
body: new ReadableStream(),
90+
body,
9091
get duplex() {
9192
duplexAccessed = true
9293
return "half"
9394
}
9495
} as globalThis.RequestInit)
95-
return duplexAccessed && !request.headers.has("Content-Type")
96+
// Bun and Deno preserve the stream without reading the duplex option.
97+
return (duplexAccessed || request.body === body) && !request.headers.has("Content-Type")
9698
} catch {
9799
return false
98100
}

0 commit comments

Comments
 (0)