Skip to content

Commit 03001fc

Browse files
authored
fix(listener): In Node.js v24, some response bodies are not read to the end until the next task queue. (#265)
1 parent b7e7b58 commit 03001fc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/listener.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ const responseViaResponseObject = async (
139139
done = true
140140
})
141141
if (!chunk) {
142+
if (i === 1 && resHeaderRecord['transfer-encoding'] !== 'chunked') {
143+
// XXX: In Node.js v24, some response bodies are not read all the way through until the next task queue,
144+
// so wait a moment and retry. (e.g. new Blob([new Uint8Array(contents)]) )
145+
await new Promise((resolve) => setTimeout(resolve))
146+
i--
147+
continue
148+
}
149+
142150
// Error occurred or currentReadPromise is not yet resolved.
143151
// If an error occurs, immediately break the loop.
144152
// If currentReadPromise is not yet resolved, pass it to writeFromReadableStreamDefaultReader.

0 commit comments

Comments
 (0)