How do I capture a “response end” event in node.js+express?

Strangely enough, it appears that the response emits a “finish” event when the response is closed:
https://web.archive.org/web/20120825112648/http://sambro.is-super-awesome.com/2011/06/27/listening-for-end-of-response-with-nodeexpress-js/

Despite this blog entry being a bit old, this event still exists (Line 836 in lib/http.js), so I assume it won’t disappear soon, even though neither node’s nor express’ documentation mention it.
By early 2014 it has moved to line 504 on of lib/_http_outgoing.js and still works.

By the way, the “error” event on a server response is probably not something you’d usually want to see.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)