Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Fix: prevent crash when stdoutRing or stderrRing is undefined #1321

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ module.exports = function(proto) {
self.processTimer = setTimeout(function() {
var msg = 'process ran into a timeout (' + self.options.timeout + 's)';

emitEnd(new Error(msg), stdoutRing.get(), stderrRing.get());
if (!stdoutRing || !stderrRing) {
self.logger?.warn?.('stdoutRing or stderrRing is undefined during timeout.');
}

emitEnd( new Error(msg), stdoutRing?.get?.() ?? null, stderrRing?.get?.() ?? null );
ffmpegProc.kill();
}, self.options.timeout * 1000);
}
Expand Down Expand Up @@ -495,7 +499,10 @@ module.exports = function(proto) {
self.logger.debug('Output stream error, killing ffmpeg process');
var reportingErr = new Error('Output stream error: ' + err.message);
reportingErr.outputStreamError = err;
emitEnd(reportingErr, stdoutRing.get(), stderrRing.get());
if (!stdoutRing || !stderrRing) {
self.logger?.warn?.('stdoutRing or stderrRing is undefined during output stream error.');
}
emitEnd( reportingErr, stdoutRing?.get?.() ?? null, stderrRing?.get?.() ?? null );
ffmpegProc.kill('SIGKILL');
});
}
Expand Down Expand Up @@ -540,7 +547,11 @@ module.exports = function(proto) {
err.message += ': ' + utils.extractError(stderrRing.get());
}

emitEnd(err, stdoutRing.get(), stderrRing.get());
if(!stdoutRing || !stderrRing) {
self.logger?.warn?.('stdoutRing or stderrRing is undefined – FFmpeg may have exited early.')
}

emitEnd( err, stdoutRing?.get?.() ?? null, stderrRing?.get?.() ?? null );
} else {
// Find out which outputs need flv metadata
var flvmeta = self._outputs.filter(function(output) {
Expand Down