From cc387accce2530ff18f6a806df4de4890a27775d Mon Sep 17 00:00:00 2001 From: Dave Foley Date: Tue, 11 Oct 2016 09:23:19 -0700 Subject: [PATCH] Attach to stderr in toBuffer In cases where stderr streams a lot of diagnostic, the process would block waiting for stderr buffer flush. We saw this occur with a PDF (ghostscript logging warnings). --- lib/command.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/command.js b/lib/command.js index 2ff464fe..c8341ed5 100644 --- a/lib/command.js +++ b/lib/command.js @@ -159,11 +159,14 @@ module.exports = function (proto) { throw new Error('gm().toBuffer() expects a callback.'); } - return this.stream(format, function (err, stdout) { + return this.stream(format, function (err, stdout, stderr) { if (err) return callback(err); + stderr.on('data', function(data) { + debug('stderr ' + data.toString('utf-8')); + }); streamToUnemptyBuffer(stdout, callback); - }) + }); } /**