Emit 'finish' event on writable streams
See original GitHub issueSummary
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:
- Created 5 years ago
- Reactions:2
- Comments:9
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 ^^.
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.