4

I have a stream of data and I need to write it to nowhere, but without immediately stopping it. The code below writes to a file, so it keeps the connection alive for as long as the stream is going.

 request
.get(href)
.on('response', function(response) {
    console.log(response.statusCode)
    console.log(response.headers['content-type'])
})
.pipe(fs.createWriteStream("name.mp3"))

Is it possible to pipe that stream to nowhere, while still keeping the connection like fs.createWritableStream ?

I tried using dev-null (npm package), but it seems to just kill the connection immediately.

almarc
  • 1,362
  • 3
  • 10
  • 28

1 Answers1

3

Seems like a strange problem, but maybe you can use /dev/null, or the Windows equivalent explained in the post below?

How can I write to the NUL device under Windows from node.js?

I do see that you tried something similar with the dev-null package, but maybe try it without the package and see if that works.

Hein Andre Grønnestad
  • 6,687
  • 2
  • 32
  • 43