Skip to content

Instantly share code, notes, and snippets.

@evansolomon
Created March 13, 2014 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evansolomon/9535323 to your computer and use it in GitHub Desktop.
Save evansolomon/9535323 to your computer and use it in GitHub Desktop.
Even when you don't care about a stream's data, you need to make sure it's produced.
var https = require('https')
https.get('https://medium.com', function (res) {
res.on('end', function () {
console.log('You will never see this')
})
})
https.get('https://medium.com', function (res) {
// This sets the stream to flowing mode and makes sure it gets through all of its
// data so that you get an end event.
res.on('data', function () {})
res.on('end', function () {
console.log('You *will* see this')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment