I think you have a setting somewhere in your code, for example:
twit.stream('statuses/sample', function(stream) { stream.on('data', function (data) { console.log(data); }); });
Save the stream variable from the callback, for example, after stream.on() :
twit.currentTwitStream = stream;
This is just an assumption. Perhaps you have a central configuration object that will be the best place for the current thread object. With currentTwitStream you can do this:
currentTwitStream.readable is false after an error or close.currentTwitStream.destroy() destroys the stream.
source share