If I encounter an error after headers have been sent I need to be able to "kill" the connection in order to signal to the client that something went wrong. How do I do this i NodeJS/ExpressJS?
function (req, res, next) {
createStream()
.on('error', () => {
if (res.headersSent) {
/* KILL CONNECTION */
} else {
res.sendStatus(500)
}
})
.pipe(res)
}