aheckmann / gm

GraphicsMagick for node
http://aheckmann.github.com/gm/
6.95k stars 615 forks source link

`toBuffer` silently swallows `stderr` #854

Open Bersaelor opened 1 year ago

Bersaelor commented 1 year ago

When using

        .toBuffer('png', function (error, buffer) {

the actual underlying error is swallowed and we only get an opaque: Error: Stream yields empty buffer.

Example: When removing imageMagick, i.e. by

const gm = require('gm') // .subClass({ imageMagick: '7+' });

we should get the following error: (tested using .write(fileImg, (error) => {):

    ERROR   Error:  Error: Could not execute GraphicsMagick/ImageMagick: gm "convert" "./background-U3OTKXWN.png" ... "/tmp/output.png" this most likely means the gm/convert binaries can't be found
    at ChildProcess.<anonymous> (/var/task/lambda.js:24:2752)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

but with .toBuffer('png', function (error, buffer) { we only get

Error: Stream yields empty buffer
    at Socket.<anonymous> (/var/task/lambda.js:24:1101)
    at Socket.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)