Skip to content

Commit cdd2680

Browse files
committed
fix(stream): improve node.js redable stream check
avoid false detection of server response as readable stream
1 parent 7b18fa0 commit cdd2680

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/utils/response.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export function isStream(data: any): data is Readable | ReadableStream {
177177
return false;
178178
}
179179
// Node.js Readable Streams
180-
if (typeof data.pipe === "function" && typeof data.on === "function") {
180+
if (typeof data.pipe === "function" && typeof data._read === "function") {
181181
return true;
182182
}
183183
// Web Streams
@@ -227,7 +227,7 @@ export function sendStream(
227227

228228
// Node.js Readable streams
229229
// https://nodejs.org/api/stream.html#readable-streams
230-
if ("pipe" in stream) {
230+
if ("pipe" in stream && "_read" in stream) {
231231
return new Promise<void>((resolve, reject) => {
232232
stream.pipe(event.node.res);
233233
stream.on("end", () => {

0 commit comments

Comments
 (0)