Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Re-emit close events #1

merged 1 commit into from

2 participants



In express controllers, one often binds actions to request events. I assume that purpose of pausing streams is to attach middlewares in a way that is not affecting controllers.

However there, if close is emmited in the window, if I bind to req.on 'close' in controller, event is lost in the same way data/end is. I am using it in my proxy to note 'request happened, but was interrupted', which I may lose in the pause()d window.

@tj tj merged commit 6cc1462 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 25, 2013
  1. @Almad

    Re-emit close event too

    Almad authored
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 2 deletions.
  1. +7 −2 index.js
9 index.js
@@ -1,4 +1,3 @@
module.exports = function(obj){
var onData
, onEnd
@@ -14,10 +13,16 @@ module.exports = function(obj){
events.push(['end', data, encoding]);
+ // buffer close
+ obj.on('close', onClose = function(d){
+ events.push(['close']);
+ });
return {
end: function(){
obj.removeListener('data', onData);
obj.removeListener('end', onEnd);
+ obj.removeListener('close', onClose);
resume: function(){
@@ -26,4 +31,4 @@ module.exports = function(obj){
Something went wrong with that request. Please try again.