serverless-image-handler icon indicating copy to clipboard operation
serverless-image-handler copied to clipboard

Large files cause "body size too long" error

Open isTravis opened this issue 8 years ago • 13 comments

Transforming a large (9.8MB) gif causes a body size too long error. This seems related to the 6MB body payload size, as described in the Lambda Limits page. I think this issue will face image formats other than .gif, that's just what I've seen it pop up on. Log screenshot below.

Any advice for how to work around this?

At the moment, I have an onError function on my <img /> tags that replaces the src with the original non-resized URL. But - this occurs in the worst case scenario, where we have huge files - so it's really not desirable.

screen shot 2018-07-08 at 10 10 04 am

isTravis avatar Jul 08 '18 14:07 isTravis

I was able to replicate this behavior. As you correctly pointed out, I believe here Lamdba response payload size is causing the issue. It should not be more than 6MB as per the limits page. Would saving image on S3 and returning that url in response rather than the actual image be a valid work around? Refer here for details: https://github.com/thumbor-community/aws#result-storage-settings We can explore tc_aws.result_storages.s3_storage for this use case.

gsingh04 avatar Aug 21 '18 04:08 gsingh04

Hi, Any update on this issue or did someone figure out the solution to this issue?

khawerrind avatar Feb 13 '19 21:02 khawerrind

Hi all. We're currently updating the solution and are looking into output storage to an S3 bucket (either a default bucket or specified in the request) as a workaround to the Lambda payload limit. Thanks for your feedback/patience!

hayesry avatar Feb 26 '19 15:02 hayesry

I just ran into this with a JPEG unfortunately (reference here: https://docs.aws.amazon.com/lambda/latest/dg/limits.html) Only recommendation I can give is for people to use the filters:quality(40) URL param option in cases where the image fails to load.

It's a bummer, and I'll post back if I come up with any other clever approach to this.

onassar avatar May 08 '19 03:05 onassar

@hayesry any update on the workaround?

brik-dm avatar May 08 '19 09:05 brik-dm

We have added this as a feature request to our backlog for an upcoming release, but don't have an ETA for when it will be ready. Marking the ticket for closure in the meantime.

hayesry avatar Jun 13 '19 17:06 hayesry

Thanks @hayesry Really looking forward to this; it's been a tough one to work around :(

onassar avatar Jun 14 '19 20:06 onassar

that's sad we're trying to deploy a storybook and there's a js file which exceed just 300kb 🤦🏻‍♂️ . it's a vendor file chunk so we can not even try to cut something off to reach out the 5mb limit. zeit/now is pure love but for this reason we're having to host in another place.

stewones avatar Jun 27 '19 18:06 stewones

that's sad we're trying to deploy a storybook and there's a js file which exceed just 300kb 🤦🏻‍♂️ . it's a vendor file chunk so we can not even try to cut something off to reach out the 5mb limit. zeit/now is pure love but for this reason we're having to host in another place.

where are you hosting this now ? If not zeit/now ?

videoAbyss avatar Aug 07 '19 06:08 videoAbyss

@videoAbyss we’re using a static server. For now firebase hosting

stewones avatar Aug 07 '19 18:08 stewones

My json data response is 750kb (<<5MB). Why am I also getting this error? @stewwan if your file is 300kb why do you get the error too?

pbirsinger avatar Aug 29 '19 12:08 pbirsinger

Hi, any updates about this ?

redayoub avatar Jan 19 '22 14:01 redayoub

@redayoub have this feature in our backlog, please follow https://github.com/aws-solutions/serverless-image-handler/issues/322.

bitcldr avatar Jan 19 '22 15:01 bitcldr