diff --git a/lib/Voice/AudioEncoder.js b/lib/Voice/AudioEncoder.js index 84ec8e004..d6a8b9505 100644 --- a/lib/Voice/AudioEncoder.js +++ b/lib/Voice/AudioEncoder.js @@ -89,7 +89,14 @@ var AudioEncoder = (function () { var enc = _child_process2["default"].spawn(_this.getCommand(), ['-i', '-', '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']); - stream.pipe(enc.stdin); + var dest = stream.pipe(enc.stdin); + + dest.on('unpipe', function () { + return dest.destroy(); + }); + dest.on('error', function (err) { + return dest.destroy(); + }); _this.hookEncodingProcess(resolve, reject, enc, stream); }); diff --git a/src/Voice/AudioEncoder.js b/src/Voice/AudioEncoder.js index ac4ac3335..18af17b77 100644 --- a/src/Voice/AudioEncoder.js +++ b/src/Voice/AudioEncoder.js @@ -71,7 +71,10 @@ export default class AudioEncoder { 'pipe:1' ]); - stream.pipe(enc.stdin); + var dest = stream.pipe(enc.stdin); + + dest.on('unpipe', () => dest.destroy()); + dest.on('error', err => dest.destroy()); this.hookEncodingProcess(resolve, reject, enc, stream); });