tailor
tailor copied to clipboard
handle 'close' event in http.Server streams
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