sindresorhus / get-stream

Get a stream as a string, Buffer, ArrayBuffer or array
MIT License
341 stars 33 forks source link

`get-stream` does not complete when the stream has already ended #50

Closed ehmicky closed 1 year ago

ehmicky commented 1 year ago
import { Readable } from 'node:stream'
import { setTimeout } from 'node:timers/promises'
import getStream from 'get-stream'

const stream = Readable.from([])
stream.read()
await setTimeout(0)
await getStream(stream)
console.log('done')

With Node >=18.14.0 and >=19.5.0, done is not printed. With Node <18.4.0 and <19.5.0, done is printed.

In other words, get-stream never completes when the stream has already ended.

This seems to be a bug with Node.js: https://github.com/nodejs/node/issues/46595

This is related to the following line in get-stream:

https://github.com/sindresorhus/get-stream/blob/8f004f946a6882c21173747094b65663a5218bd6/index.js#L41

ehmicky commented 1 year ago

This was fixed by Node 19.8.0.