Skip to content

Commit a0e31a0

Browse files
Jonhamdecompi
andauthored
Fix: prevent crash when stdoutRing or stderrRing is undefined by @decompi (#3)
Co-authored-by: decompi <ytstickmanitz@gmail.com>
1 parent d054c50 commit a0e31a0

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/processor.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,11 @@ module.exports = function(proto) {
467467
self.processTimer = setTimeout(function() {
468468
var msg = 'process ran into a timeout (' + self.options.timeout + 's)';
469469

470-
emitEnd(new Error(msg), stdoutRing.get(), stderrRing.get());
470+
if (!stdoutRing || !stderrRing) {
471+
self.logger?.warn?.('stdoutRing or stderrRing is undefined during timeout.');
472+
}
473+
474+
emitEnd( new Error(msg), stdoutRing?.get?.() ?? null, stderrRing?.get?.() ?? null );
471475
ffmpegProc.kill();
472476
}, self.options.timeout * 1000);
473477
}
@@ -495,7 +499,10 @@ module.exports = function(proto) {
495499
self.logger.debug('Output stream error, killing ffmpeg process');
496500
var reportingErr = new Error('Output stream error: ' + err.message);
497501
reportingErr.outputStreamError = err;
498-
emitEnd(reportingErr, stdoutRing.get(), stderrRing.get());
502+
if (!stdoutRing || !stderrRing) {
503+
self.logger?.warn?.('stdoutRing or stderrRing is undefined during output stream error.');
504+
}
505+
emitEnd( reportingErr, stdoutRing?.get?.() ?? null, stderrRing?.get?.() ?? null );
499506
ffmpegProc.kill('SIGKILL');
500507
});
501508
}
@@ -540,7 +547,11 @@ module.exports = function(proto) {
540547
err.message += ': ' + utils.extractError(stderrRing.get());
541548
}
542549

543-
emitEnd(err, stdoutRing.get(), stderrRing.get());
550+
if(!stdoutRing || !stderrRing) {
551+
self.logger?.warn?.('stdoutRing or stderrRing is undefined – FFmpeg may have exited early.')
552+
}
553+
554+
emitEnd( err, stdoutRing?.get?.() ?? null, stderrRing?.get?.() ?? null );
544555
} else {
545556
// Find out which outputs need flv metadata
546557
var flvmeta = self._outputs.filter(function(output) {

0 commit comments

Comments
 (0)