Meteor-CollectionFS icon indicating copy to clipboard operation
Meteor-CollectionFS copied to clipboard

ENOENT Error, stream error?

Open c6y opened this issue 10 years ago • 6 comments

I'm on OSX, have Imagemagick installed and the code below works, but only sporadically. Often I get the error below and zero byte image files are written to the directory. I've tried installing Graphicsmagick but there is no improvement.

stream.js:94 W20150204-01:15:32.343(-8)? (STDERR) throw er; // Unhandled stream error in pipe. Error: ENOENT, open '/Users/kai/eboydb/.meteor/local/cfs/files/_tempstore/MyPix-HQMnDBjLstPmMxGoY-0.chunk'

function scaleToTargetByInt (width) {
    var maxWidth = 216 * 2; // 2x thumbnail size optimized for Retina display
    var originalWidth = width;
    var scaleInt = Math.floor(maxWidth/originalWidth);
    var scaleSize = scaleInt * originalWidth;
    return scaleSize;
}

var OriginalsStore = new FS.Store.FileSystem("OriginalPix", {
    path: pathToOriginalsFolder,
    transformWrite: function (fileObj, readStream, writeStream) {
        // read image dimensions and write to metadata
        gm(readStream)
        .size({bufferStream: true}, FS.Utility.safeCallback(function (err, size) {
            if (err) {
                // handle the error
            } else {
                fileObj.update({$set: {'metadata.width': size.width, 'metadata.height': size.height}});
            }
        }))
        // read metadata.width and scale acordingly
        .sample(scaleToTargetByInt(fileObj.metadata.width))
        .stream()
        .pipe(writeStream);
    }
});

c6y avatar Feb 04 '15 09:02 c6y

I have the same problem on Linux. The error prevented my meteor instance from starting up at all, I could only fix it by deleting the offending file from the CollectionFS collection.

Will try to investigate further.

theduke avatar Feb 11 '15 07:02 theduke

+1

alearcy avatar Mar 06 '15 11:03 alearcy

Just to get some idea about your setup. What meteor packages are you using/version. Can you try to use gridfs as store to compare if the problem still exists?

do you have some real code or logging at // handle the error , is there an error?

mxab avatar Mar 06 '15 12:03 mxab

I dropped server side scaling (everything is done client-side now), but the project is on GitHub. I think it is the commit from Feb 4th that was the base for the problem. I never managed to solve it though and moved on.

https://github.com/c6y/eboydb/commit/a7cfef364ea564fdefc21ecadfaa9a3b4c087a05

(apologies for the messy code)

c6y avatar Mar 06 '15 19:03 c6y

Try it like this:

gm(readStream).size({bufferStream: true}, FS.Utility.safeCallback(function (err, size) {
            if (err) {
                // handle the error
            } else {
                fileObj.update({$set: {'metadata.width': size.width, 'metadata.height': size.height}});
                this.sample(scaleToTargetByInt(size.width)).stream().pipe(writeStream);
            }
}))

If this works, please let us know so we can start to put snippets of some of these common situations in the docs.

aldeed avatar Apr 08 '15 22:04 aldeed

+1

abuddenb avatar May 10 '16 14:05 abuddenb