Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.JS: some external images fail to load with 500 #3194

Closed
5 tasks done
JanStevens opened this issue Dec 12, 2022 · 24 comments
Closed
5 tasks done

Next.JS: some external images fail to load with 500 #3194

JanStevens opened this issue Dec 12, 2022 · 24 comments
Assignees
Labels
archived This issue has been locked. bug Something isn't working compute

Comments

@JanStevens
Copy link

Before opening, please confirm:

  • I have checked to see if my question is addressed in the FAQ.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

App Id

dajig6o8wd38u

AWS Region

eu-west-1

Amplify Hosting feature

Not Applicable

Describe the bug

Some images fail to be optimized by next/image. For example the following image gives a 500 error:

https://develop.dajig6o8wd38u.amplifyapp.com/_next/image?url=https%3A%2F%2Fwww.datocms-assets.com%2F61856%2F1663872821-mdlbeast_soundstorm_28.png&w=1080&q=75

In the cloudwatch logs we can observe

Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly

Expected behavior

The image should correctly be optimised

Reproduction steps

  1. The source image (can be found here: https://www.datocms-assets.com/61856/1663872821-mdlbeast_soundstorm_28.png) should be used in an Next Image
  2. Example Next Image tag
<Image
  alt="image"
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mPU1Tb8DwACoAGKo/qR9AAAAABJRU5ErkJggg=="
  layout="fill"
  objectFit="cover"
  placeholder="blur"
  sizes="(min-width: 900px) 800px, 300px"
  src="https://www.datocms-assets.com/61856/1663872821-mdlbeast_soundstorm_28.png"
/>

Build Settings

No response

Log output

# Put your logs below this line
Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly

Additional information

It seems that this is only the case for really large images, the example image is for example 49mb

@JanStevens JanStevens added bug Something isn't working pending-triage labels Dec 12, 2022
@ghost ghost added the compute label Dec 12, 2022
@oliver-leung
Copy link

Hi @JanStevens, have you attempted these troubleshooting steps from the official Next.js documentation? https://nextjs.org/docs/messages/sharp-missing-in-production

@JanStevens
Copy link
Author

Hi @JanStevens, have you attempted these troubleshooting steps from the official Next.js documentation? https://nextjs.org/docs/messages/sharp-missing-in-production

Yes, I've installed the sharp dependency manually, I do want to point out that according to Amplify docs you don't have to do that, see: https://docs.aws.amazon.com/amplify/latest/userguide/ssr-Amplify-support.html

But it's clear that this is not happening at all, hence the issue

@ghost ghost self-assigned this Jan 18, 2023
@ghost ghost added investigating and removed pending-triage labels Jan 18, 2023
@Jay2113
Copy link
Contributor

Jay2113 commented Mar 29, 2023

Hi @JanStevens 👋 , apologies for the delayed response here. Are you still running into this issue?

Can you confirm if your app is using images > 4.3MB in size? We have updated our docs to reflect the maximum output size of the image we support with the Amplify Hosting Compute platform: https://docs.aws.amazon.com/amplify/latest/userguide/ssr-Amplify-support.html#image-optimization

The maximum output size of the image can't exceed 4.3 MB. You can have a larger image file stored somewhere and use the next/image component to resize and optimize it into a Webp or AVIF format and then serve it as a smaller size.

@Jay2113 Jay2113 added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating labels Mar 29, 2023
@Jay2113 Jay2113 self-assigned this Mar 29, 2023
@github-actions
Copy link

github-actions bot commented Apr 1, 2023

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Apr 1, 2023
@JanStevens
Copy link
Author

Hi @JanStevens 👋 , apologies for the delayed response here. Are you still running into this issue?

Can you confirm if your app is using images > 4.3MB in size? We have updated our docs to reflect the maximum output size of the image we support with the Amplify Hosting Compute platform: https://docs.aws.amazon.com/amplify/latest/userguide/ssr-Amplify-support.html#image-optimization

The maximum output size of the image can't exceed 4.3 MB. You can have a larger image file stored somewhere and use the next/image component to resize and optimize it into a Webp or AVIF format and then serve it as a smaller size.

Hi, I do see the docs are updated, but I want to point out we are still having the issue where sharp is required to be installed in standalone mode for the image optimization to function correctly.

We will try the good old: did you try turning it off and on again (trash project in amplify, add it again)

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Apr 3, 2023
@JanStevens
Copy link
Author

@Jay2113 I've just tried again and same issue. In cloud watch I see

Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly

And I notice that none of my images are being processed, ex: the banner is a full 3,7MB image 😞

https://develop.dqt3z8udsbg6k.amplifyapp.com/

@onerdy
Copy link

onerdy commented Apr 11, 2023

@JanStevens @Jay2113

Any luck with this issue? I seem to be having the same problem. Even after adding Sharp to my project and redeploying to Amplify, my images don't show up.

@d-strygwyr
Copy link

any update on this issue? i have same problem

image

@sdlfkorg
Copy link

sdlfkorg commented Apr 19, 2023

update (2023/04/20):
might be helpful for the guys have similar issue:
I downgrade nextjs to version 13.2.4 and everything is going well.
ref: #3428

Also have similar problem, the project is hosted on aws amplify.
Everything is ok in nextjs 12, but the image will have 500 internal error when upgrade to 13.
It seems amplify cannot support the new Image component very well?
I didn't see this problem on Vercel.
now what I cann do is setting the images to be unoptimized in next.config.js to get rid of this issue and wait for update.

@onerdy
Copy link

onerdy commented Apr 21, 2023

update (2023/04/20): might be helpful for the guys have similar issue: I downgrade nextjs to version 13.2.4 and everything is going well. ref: #3428

It looks like downgrading the version of Nextjs fixed my issue as well. I changed my package.json from "next": "latest" (which was running 13.3.0) to "next": "~13.2.4" and now the Image optimization appears to be working on AWS Amplify.

@subhasish-smiles
Copy link

subhasish-smiles commented Jun 27, 2023

Trying to load aws-s3 images with next/image in version 13.4.7. Facing this same problem. Some images are not loading sometimes. Don't want to downgrade.

@bigboypantson
Copy link

Getting this issue still, tried next latest and v13.3, getting 500 response codes on Amplify with next/image component...

Going to try downgrade as suggested, anything being done to address this issue?

Thanks

@d-strygwyr
Copy link

AWS-amplify not maintained again? this product has dead?

@bigboypantson
Copy link

bigboypantson commented Jun 30, 2023 via email

@d-strygwyr
Copy link

I updated my next version to next release and issue was fixed.

has fixed with next rc version ?

@onerdy
Copy link

onerdy commented Jun 30, 2023

I updated my next version to next release and issue was fixed.

What is the version number that is working for you now?

@bigboypantson
Copy link

Going up to 13.4.6 from 13.3.0 made it work.

@bigboypantson
Copy link

Sorry, wasn't the very NEXT release as I stated previously.

@ghost ghost removed their assignment Jul 7, 2023
@S4Mi
Copy link

S4Mi commented Jul 14, 2023

For me the problem seemed to be with the 'sharp' package, once removed it was fixed.

@Alikhan2904
Copy link

I'm using NEXT version 13.4.17 and the images are not getting rendered for me. Also, I can't downgrade the version as the application is using some newer features such as server components which are not supported before NEXT 13.4. Is there any other way around?

@d-strygwyr
Copy link

I'm using NEXT version 13.4.17 and the images are not getting rendered for me. Also, I can't downgrade the version as the application is using some newer features such as server components which are not supported before NEXT 13.4. Is there any other way around?

Do you have to try @S4Mi mention? remove Sharp on dependency?

@Jay2113
Copy link
Contributor

Jay2113 commented Mar 12, 2024

Hi everyone 👋 , towards the end of last year (Nov '23) we launched support for image optimization for all SSR apps and the issue outlined in this thread should no longer occur with it. To learn more about Amplify Hosting's built-in image optimization feature, refer to this documentation: https://docs.aws.amazon.com/amplify/latest/userguide/image-optimization.html.

@Jay2113 Jay2113 closed this as completed Mar 12, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Copy link

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Mar 12, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. bug Something isn't working compute
Projects
None yet
Development

No branches or pull requests

10 participants