Fix up VideoStreamer stability, it was user error

This commit is contained in:
Alex Hultman 2019-01-17 09:39:03 +01:00
parent 4ae2facba7
commit 26e25ec2ed

View File

@ -42,16 +42,16 @@ function pipeStreamOverResponse(res, readStream, totalSize) {
} }
return false; return false;
}); });
/* Register async abortion handlers */
res.onAborted(() => {
console.log('Res is no longer valid!');
readStream.destroy();
});
} }
}).on('end', () => { }).on('end', () => {
/* Todo: handle errors of the stream, probably good to simply close the response */ /* Todo: handle errors of the stream, probably good to simply close the response */
}); });
/* If you plan to asyncronously respond later on, you MUST listen to onAborted BEFORE returning */
res.onAborted(() => {
console.log('Res is no longer valid!');
readStream.destroy();
});
} }
/* Yes, you can easily swap to SSL streaming by uncommenting here */ /* Yes, you can easily swap to SSL streaming by uncommenting here */