From 26e25ec2edb035235bf4199df63778b8ddaba619 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Thu, 17 Jan 2019 09:39:03 +0100 Subject: [PATCH] Fix up VideoStreamer stability, it was user error --- examples/VideoStreamer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/VideoStreamer.js b/examples/VideoStreamer.js index 6f8a00f..a4bf5fa 100644 --- a/examples/VideoStreamer.js +++ b/examples/VideoStreamer.js @@ -42,16 +42,16 @@ function pipeStreamOverResponse(res, readStream, totalSize) { } return false; }); - - /* Register async abortion handlers */ - res.onAborted(() => { - console.log('Res is no longer valid!'); - readStream.destroy(); - }); } }).on('end', () => { /* 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 */