Skip to content

Commit

Permalink
Merge pull request fluent-ffmpeg#920 from c24w/master
Browse files Browse the repository at this point in the history
Clear process timeout timer when command completes
  • Loading branch information
njoyard authored Jul 11, 2019
2 parents 22db625 + a9ebbd3 commit d74149d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,8 @@ module.exports = function(proto) {
}

// Setup timeout if requested
var processTimer;
if (self.options.timeout) {
processTimer = setTimeout(function() {
self.processTimer = setTimeout(function() {
var msg = 'process ran into a timeout (' + self.options.timeout + 's)';

emitEnd(new Error(msg), stdoutRing.get(), stderrRing.get());
Expand Down Expand Up @@ -533,6 +532,7 @@ module.exports = function(proto) {
},

function endCB(err, stdoutRing, stderrRing) {
clearTimeout(self.processTimer);
delete self.ffmpegProc;

if (err) {
Expand Down
12 changes: 12 additions & 0 deletions test/processor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,18 @@ describe('Processor', function() {
.saveToFile(testFile);
});

it('should not keep node process running on completion', function(done) {
var script = `
var ffmpeg = require('.');
ffmpeg('${this.testfilebig}', { timeout: 60 })
.addOption('-t', 1)
.addOption('-f', 'null')
.saveToFile('/dev/null');
`;

exec(`node -e "${script}"`, { timeout: 1000 }, done);
});

it('should kill the process with .kill', function(done) {
var testFile = path.join(__dirname, 'assets', 'testProcessKill.avi');
this.files.push(testFile);
Expand Down

0 comments on commit d74149d

Please sign in to comment.