question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Emit 'finish' event on writable streams

See original GitHub issue

Summary

According to the documentation readable streams emit ‘end’ and writable streams emit ‘finish’. However, request seems to always emit ‘end’.

Simplest Example to Reproduce

const fs = require('fs')
const path = require('path')
const request = require('request')


const postReq = request({
    method: 'POST',
    uri: 'http://devnull-as-a-service.com/dev/null',
  })

postReq.on('finish', () => console.log('This should be called!'))

fs
  .createReadStream(path.join(__dirname, 'index.js'))
  .pipe(postReq)

Expected Behavior

Outputs This should be called!

Current Behavior

Does nothing

Your Environment

software version
request 2.85.0
node 9.10.1
Operating System macOS

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

7reactions
ad-sicommented, Apr 26, 2018

Sorry, I’m not working with JavaScript anymore. => Haskell That even a project as popular and prevalent as request doesn’t implement the streaming API correctly says a lot about the ecosystem ^^.

0reactions
stale[bot]commented, Jun 4, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js Writable Stream finish Event - GeeksforGeeks
The 'finish' event in a Writable Stream is emitted after the Calling of writable.end() method when all the data is being flushed to...
Read more >
Stream | Node.js v19.3.0 Documentation
The 'finish' event is emitted after the stream.end() method has been called, and all data has been flushed to the underlying system. const...
Read more >
How can I send an "end" event to Nodejs stream
It's not meant to be used with writables. The finish event is used for writable streams when .end() has been called and the...
Read more >
Understanding Streams in Node.js - NodeSource
The writable stream will let you know when you can start writing more data by emitting a drain event. Calling the writable.end() method ......
Read more >
Writable#end does not trigger 'finish' event: why? · Issue #2112
The 'finish' event is emitted after the stream.end() method has been called, and all data has been flushed to the underlying system.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found