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 beta app directory - random problem with local Images #48820

Closed
1 task done
dawid-boruta-fabres opened this issue Apr 25, 2023 · 10 comments
Closed
1 task done

Next beta app directory - random problem with local Images #48820

dawid-boruta-fabres opened this issue Apr 25, 2023 · 10 comments
Labels
bug Issue was opened via the bug report template. locked stale The issue has not seen recent activity.

Comments

@dawid-boruta-fabres
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Docker image from latest Next example

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue

It's random

To Reproduce

No way to reproduce.

Describe the Bug

I have random problem with next images served from public directory.
Currently i'm using latest v13.3.1 with beta App directory - but i had the same problem on all v13.3.1 canary versions.

It's random - sometimes all images are working correctly sometime not. For example right now i have a banner with srcset:

/_next/image?url=%2Fbanner-desktop.jpeg&w=640&q=75 640w, /_next/image?url=%2Fbanner-desktop.jpeg&w=750&q=75 750w, /_next/image?url=%2Fbanner-desktop.jpeg&w=828&q=75 828w, /_next/image?url=%2Fbanner-desktop.jpeg&w=1080&q=75 1080w, /_next/image?url=%2Fbanner-desktop.jpeg&w=1200&q=75 1200w, /_next/image?url=%2Fbanner-desktop.jpeg&w=1920&q=75 1920w, /_next/image?url=%2Fbanner-desktop.jpeg&w=2048&q=75 2048w, /_next/image?url=%2Fbanner-desktop.jpeg&w=3840&q=75 3840w"

All sizes are working correctly except one: /_next/image?url=%2Fbanner-desktop.jpeg&w=1200&q=75
It's pending forever without any error message or timeout. What's more funny if i'll change query param q from 75 to any different number for example /_next/image?url=%2Fbanner-desktop.jpeg&w=1200&q=76 - it'll work.

It's random without any way to reproduce it or errors in logs, sentry etc.
Is there any way to debug it?

Expected Behavior

It should serve an image.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@dawid-boruta-fabres dawid-boruta-fabres added the bug Issue was opened via the bug report template. label Apr 25, 2023
@JesseKoldewijn
Copy link
Contributor

Do you have a reproduction repo or codesandbox or something like it where it runs into this issue by chance?

@dawid-boruta-fabres
Copy link
Author

OK i spent few hours to create repetitive scenario on local environment. It looks like a problem with sharp. after removing sharp - it works fine:

git clone https://github.com/diabelb/next-bug
cd next-bug
docker build . -t next-bug
sleep 10; docker run next-bug

Right now you have 10 seconds to make some load on example image.
Go to Chrome -> enter http://localhost:3000/_next/image?url=%2Fbanner-desktop.jpeg&w=1200&q=75 ->
then hold command+shift+R (or windows/linux equivalent) to make some load

On first container start above endpoint will hang forever. This fails only on first start. To repeat this problem you need to rebuild docker container with different image tag. You can use any image width.

In real world scenario this is a huge problem. On every deployment to docker environment i have some broken images that loads forever.

@joacub
Copy link

joacub commented Apr 25, 2023

and in turbo pack is not working at all, I already rise this bug but seems not be followed, I hope this one gets tracked

@mendoanjoe
Copy link

i have same issue, i am using import like import logoWhite from '../../../../public/logo-white.png' to make this work

@joacub
Copy link

joacub commented Apr 27, 2023

i have same issue, i am using import like import logoWhite from '../../../../public/logo-white.png' to make this work

webpack or turbopack ?

@mendoanjoe
Copy link

i have same issue, i am using import like import logoWhite from '../../../../public/logo-white.png' to make this work

webpack or turbopack ?

i am using webpack.

try this https://nextjs.org/docs/advanced-features/output-file-tracing
add into next.config output: 'standalone', and add sharp to package.json, i think is more stable

@joacub
Copy link

joacub commented Apr 29, 2023

i have same issue, i am using import like import logoWhite from '../../../../public/logo-white.png' to make this work

webpack or turbopack ?

i am using webpack.

try this https://nextjs.org/docs/advanced-features/output-file-tracing add into next.config output: 'standalone', and add sharp to package.json, i think is more stable

Webpack work as expected to me, is turbopack which is not working with images.

styfle added a commit that referenced this issue Feb 6, 2024
…ep (#61696)

## History

Previously, we added support for `squoosh` because it was a wasm
implementation that "just worked" on all platforms when running `next
dev` for the first time. However, it was slow so we always recommended
manually installing `sharp` for production use cases running `next
build` and `next start`.

Now that [`sharp` supports
webassembly](https://sharp.pixelplumbing.com/install#webassembly), we no
longer need to maintain `squoosh`, so it can be removed. We also don't
need to make the user install sharp manually because it can be installed
under `optionalDependencies`. I left it optional in case there was some
platform that still needed to manually install the wasm variant with
`npm install --cpu=wasm32 sharp` such as codesandbox/stackblitz (I don't
believe sharp has any fallback built in yet).

Since we can guarantee `sharp`, we can also remove `get-orientation` dep
and upgrade `image-size` dep.

I also moved an [existing `sharp`
test](#56674) into its own fixture
since it was unrelated to image optimization.

## Related Issues
- Fixes #41417
- Closes #54670
- Related #54708
- Related #44804
- Related #48820
styfle added a commit that referenced this issue Apr 25, 2024
…ependency (#63321)

## History

Previously, we added support for `squoosh` because it was a wasm
implementation that "just worked" on all platforms when running `next
dev` for the first time. However, it was slow so we always recommended
manually installing `sharp` for production use cases running `next
build` and `next start`.

Now that [`sharp` supports
webassembly](https://sharp.pixelplumbing.com/install#webassembly), we no
longer need to maintain `squoosh`, so it can be removed. We also don't
need to make the user install sharp manually because it can be installed
under `optionalDependencies`. I left it optional in case there was some
platform that still needed to manually install the wasm variant with
`npm install --cpu=wasm32 sharp` such as codesandbox/stackblitz (I don't
believe sharp has any fallback built in yet).

Since we can guarantee `sharp`, we can also remove `get-orientation` dep
and upgrade `image-size` dep.

I also moved an [existing `sharp`
test](#56674) into its own fixture
since it was unrelated to image optimization.

## Related Issues
- Fixes #41417
- Related #54670
- Related #54708
- Related #44804
- Related #48820
- Related #61810
- Related #61696
- Related #44685
- Closes #64362

## Breaking Change

This is a breaking change because newer versions of `sharp` no longer
support `yarn@1`.

- lovell/sharp#3750

The workaround is to install with `yarn --ignore-engines` flag.

Also note that Vercel no longer defaults to yarn when no lockfile is
found

- vercel/vercel#11131
- vercel/vercel#11242

Closes NEXT-2823
ForsakenHarmony pushed a commit that referenced this issue Aug 16, 2024
…ependency (#63321)

## History

Previously, we added support for `squoosh` because it was a wasm
implementation that "just worked" on all platforms when running `next
dev` for the first time. However, it was slow so we always recommended
manually installing `sharp` for production use cases running `next
build` and `next start`.

Now that [`sharp` supports
webassembly](https://sharp.pixelplumbing.com/install#webassembly), we no
longer need to maintain `squoosh`, so it can be removed. We also don't
need to make the user install sharp manually because it can be installed
under `optionalDependencies`. I left it optional in case there was some
platform that still needed to manually install the wasm variant with
`npm install --cpu=wasm32 sharp` such as codesandbox/stackblitz (I don't
believe sharp has any fallback built in yet).

Since we can guarantee `sharp`, we can also remove `get-orientation` dep
and upgrade `image-size` dep.

I also moved an [existing `sharp`
test](#56674) into its own fixture
since it was unrelated to image optimization.

## Related Issues
- Fixes #41417
- Related #54670
- Related #54708
- Related #44804
- Related #48820
- Related #61810
- Related #61696
- Related #44685
- Closes #64362

## Breaking Change

This is a breaking change because newer versions of `sharp` no longer
support `yarn@1`.

- lovell/sharp#3750

The workaround is to install with `yarn --ignore-engines` flag.

Also note that Vercel no longer defaults to yarn when no lockfile is
found

- vercel/vercel#11131
- vercel/vercel#11242

Closes NEXT-2823
@nextjs-bot
Copy link
Collaborator

This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.

@nextjs-bot nextjs-bot added the stale The issue has not seen recent activity. label Feb 8, 2025
@nextjs-bot
Copy link
Collaborator

This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding!

@nextjs-bot nextjs-bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 15, 2025
Copy link
Contributor

github-actions bot commented Mar 2, 2025

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot added the locked label Mar 2, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked stale The issue has not seen recent activity.
Projects
None yet
Development

No branches or pull requests

5 participants