Skip to content

Node exits on Invalid File Signature with certain images #359

@dvoraqs

Description

@dvoraqs

We are trying to use Quagga in Node with the Node example code using Quagga.decodeSingle and it exits with this error with some specific images:

Error: Invalid file signature
    at module.exports.Parser._parseSignature (/Users/dvoraqs/ccom/service/node_modules/pngjs/lib/parser.js:50:18)
    at module.exports.ChunkStream._processRead (/Users/dvoraqs/ccom/service/node_modules/pngjs/lib/chunkstream.js:174:13)
    at module.exports.ChunkStream._process (/Users/dvoraqs/ccom/service/node_modules/pngjs/lib/chunkstream.js:193:14)
    at module.exports.ChunkStream.write (/Users/dvoraqs/ccom/service/node_modules/pngjs/lib/chunkstream.js:61:8)
    at module.exports.ChunkStream.end (/Users/dvoraqs/ccom/service/node_modules/pngjs/lib/chunkstream.js:74:10)
    at exports.PNG.PNG.end (/Users/dvoraqs/ccom/service/node_modules/pngjs/lib/png.js:98:16)
    at exports.PNG.PNG.parse (/Users/dvoraqs/ccom/service/node_modules/pngjs/lib/png.js:88:8)
    at handlePNG (/Users/dvoraqs/ccom/service/node_modules/get-pixels/node-pixels.js:17:7)
    at doParse (/Users/dvoraqs/ccom/service/node_modules/get-pixels/node-pixels.js:109:7)
    at /Users/dvoraqs/ccom/service/node_modules/get-pixels/node-pixels.js:190:7
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:528:3)
events.js:136
      throw er; // Unhandled 'error' event
      ^

I tried to look around at the code in Quagga and identified this as a possible culprit of the app crashing inside of input_stream.js:

...
function loadImages() {
        loaded = false;
        GetPixels(baseUrl, _config.mime, function(err, pixels) {
            if (err) {
                console.log(err);
                exit(1);
            }
...

Our application is an Express web app that shouldn't exit if it can't process an image. This is problematic in our case because our app cannot fail gracefully and return a response to the user if it just exits. Can this error just be thrown back to your consumer to handle in whatever way they like?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions