serverless-next.js icon indicating copy to clipboard operation
serverless-next.js copied to clipboard

Image optimization timeout when requesting specific webp image, but named as png file

Open StaymanHou opened this issue 2 years ago • 0 comments

Issue Summary

The image optimization lambda invocation times out (we have it set to default 10 sec) when requesting a specific image. A copy of the image here Please note that the image is a webp image but the user uploaded it with the *.png filename. Simply changing the file extension to .webp would make the lambda function process the image correctly.

Actual behavior

Requesting https://<domain.com>/_next/image?url=<url-to-that-crafted-webp-image.png>&w=***&q=*** will cause the corresponding lambda invocation to time out. Nothing else in the log. Requesting the same image locally doesn't experience the same isssue.

Expected behavior

Either process the image normally as if it's just an webp image with the .webp file extension; Or immediately return an HTTP error instead of hanging there waiting for the invocation to timeout.

Steps to reproduce

  • Deploy a nextjs application using serverless
  • Upload the image above to an S3 bucket and make it publicly accessbile
  • Add the s3 domain to the permitted image src domain list
  • Request the image from the image optimization endpoint

Screenshots/Code/Configuration/Logs

Selection_932

# serverless.yml
MyApp:
  component: "../../node_modules/@sls-next/serverless-component"
  inputs:
    cloudfront:
      distributionId: *************
      _next/image*:
        forward:
          cookies: 'none'
    timeout:
      regenerationLambda: 30

Versions

  • OS/Environment: Ubuntu
  • @sls-next/serverless-component version: 3.6.0
  • Next.js version: 11.1.2

Checklist

  • [x] You have reviewed the README and FAQs, which answers several common questions.
  • [x] You have reviewed our DEBUGGING wiki and have tried your best to include complete information and reproduction steps (including your configuration) as is possible. As there is only one maintainer (who maintains this in his free time) and thus very limited resources, if you have time, please try to debug the issue a bit yourself if possible.
  • [ ] You have first tried using the most recent latest or alpha @sls-next/serverless-component release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.

StaymanHou avatar Apr 29 '22 19:04 StaymanHou