jimmynicol/image-resizer

App crashes whenever image is not found

Closed this issue · 2 comments

risul commented

Hi,

Testing 1.0 on both localhost and heroku..
It seems that the app creashes whenever an image is not found.

I have only tested twitter and facebook for now and getting this error:

/home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/node_modules/map-stream/index.js:103
        throw err
              ^
Error: Buffer contains an unsupported image format. JPEG, PNG, WebP and TIFF are currently supported.
    at new Sharp (/home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/node_modules/sharp/index.js:81:13)
    at Sharp (/home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/node_modules/sharp/index.js:16:12)
    at /home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/src/streams/resize.js:44:13
    at wrappedMapper (/home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/node_modules/map-stream/index.js:84:19)
    at Stream.stream.write (/home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/node_modules/map-stream/index.js:96:21)
    at Stream.ondata (stream.js:51:26)
    at Stream.emit (events.js:95:17)
    at queueData (/home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/node_modules/map-stream/index.js:43:21)
    at next (/home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/node_modules/map-stream/index.js:71:7)
    at /home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/node_modules/map-stream/index.js:85:7
    at /home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/src/streams/identify.js:17:14
    at wrappedMapper (/home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/node_modules/map-stream/index.js:84:19)
    at Stream.stream.write (/home/ubuntu/workspace/projects/image.server/node_modules/image-resizer/node_modules/map-stream/index.js:96:21)
    at write (_stream_readable.js:602:24)
    at flow (_stream_readable.js:611:7)
    at Facebook.pipeOnReadable (_stream_readable.js:643:5)

... same error if I call for a twitter profile image that is not found.

Could this be related to #46?

risul commented

Hi,

Any comments to guide me into right direction is highly appreciated!
Thanks!

Hi @risul,

Sorry I was able to respond earlier. I fixed the issue you were seeing here, request was not passing through the 404 states like I was expecting via the stream. I converted all the 3rd party sources to using request in that fashion to a callback pattern which handles errors in a better way.

v1.0.1 has the fixes you need.

Please let me know if this fixes it for you.