Git Product home page Git Product logo

Comments (3)

aheckmann avatar aheckmann commented on July 17, 2024

can you provide a test case. want to make sure it's fixed properly

from gm.

dpup avatar dpup commented on July 17, 2024

Sure thing. Given the following code:

var url = require('url')
var http = require('http')
var gm = require('gm')

http.get(url.parse('http://www.google.com/images/srpr/logo3w.png'), function (resp) {
  gm(resp, 'logo3w.png').stream(function (err, stdout, stderr) {
    if (err) {
      console.error('Error processing image', err)
    } else {
      stdout.on('data', function (chunk) {
        console.log('Chunk recieved', chunk.length)
      })
      stdout.on('end', function () {
        console.log('Stream ended')
      })
    }
  })
})
.on('error', function (err) {
  console.error('Error fetching image', err)
})

With graphicsmagick installed:

$ node gm-test.js 
Chunk recieved 7078
Stream ended

If gm is not installed I would expect:

$ node gm-test.js 
Error processing image, Error: graphicsmagick not available.
    at [some nice stack trace]

What actually happens if gm is not installed:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: write EPIPE
    at errnoException (net.js:670:11)
    at Object.afterWrite [as oncomplete] (net.js:503:19)

Note, none of the error callbacks are called.

Thanks for looking.

from gm.

aheckmann avatar aheckmann commented on July 17, 2024

tracked it down. the callback to gm(resp, 'logo3w.png').stream(function (err, stdout, stderr) { is already called by the time the error occurs on the internal child process stdin stream so its too late to pass the err to the callback. instead, to detect this case you can test the output of stderr for "execvp(): No such file or directory"

from gm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.