tailor icon indicating copy to clipboard operation
tailor copied to clipboard

handle 'close' event in http.Server streams

Open tadjik1 opened this issue 9 years ago • 0 comments

Hi there, there are 'close' events in node.js http.IncomeMessage and http.ServerResponse streams, and these events mean that connection was closed before response was fully passed to client (before 'end' event). It means that if you don’t handle this event on server side, your server will pipe all data through stream which has no consumer.

It's not a bug itself, it's just a possible place for avoiding extra needless work.

I wrote a simple client.js script and added logs to tailor server from your example. https://github.com/tadjik1/tailor/commit/30db7e1a66f5cf3dc43607a0e0b758c40e9c47ae Just run these commands in different terminals

npm run example
node example/client.js

and check that there are different values in received and sent logs.

received 3219
sent 4678

tadjik1 avatar Nov 10 '16 10:11 tadjik1