set encoding when reading from streams
using .toString() works most of the time but can lead to utf8 characters being broken across chunk boundaries. https://nodejs.org/api/stream.html#stream_readable_setencoding_encoding
This commit is contained in:
@@ -78,7 +78,7 @@ module.exports = OutputFileOptimiser = {
|
||||
const timer = new Metrics.Timer('qpdf')
|
||||
const proc = spawn('qpdf', args)
|
||||
let stdout = ''
|
||||
proc.stdout.on('data', chunk => (stdout += chunk.toString()))
|
||||
proc.stdout.setEncoding('utf8').on('data', chunk => (stdout += chunk))
|
||||
callback = _.once(callback) // avoid double call back for error and close event
|
||||
proc.on('error', function(err) {
|
||||
logger.warn({ err, args }, 'qpdf failed')
|
||||
|
||||
Reference in New Issue
Block a user