nodejs / readable-stream

Node-core streams for userland
https://nodejs.org/api/stream.html
Other
1.03k stars 229 forks source link

Promise version of finished not calling clean up #486

Closed rhodgkins closed 2 years ago

rhodgkins commented 2 years ago

https://github.com/nodejs/readable-stream/blob/e95c7617af81755d91aee0d3de16af9ae47960de/lib/internal/streams/end-of-stream.js#L245-L255

Should the promise version of finished call the clean up function returned from the callback version?

So something like:

function finished(stream, opts) {
  return new Promise((resolve, reject) => {
    const cleanup = eos(stream, opts, (err) => {
      cleanup()
      if (err) {
        reject(err)
      } else {
        resolve()
      }
    })
  })
}

Also raised in the main repo nodejs/node#44556

mcollina commented 2 years ago

Closed in favor of https://github.com/nodejs/node/issues/44556