node.js error : This socket is closed Node.js/gm library

am working on a project in Node.js with gm library,

every thing is going perfect but when the execution reaches this line

 gm(data).size(function (err, size) {

the execution throw an error

[Error: This socket is closed.]

i am not able to figure it out why this error occur ?

i google it with reference to gm but 0 success,

am confused whether this error is because of gm library or something else