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

icon.svg is not included in standalone output #49009

Closed
1 task done
darthmaim opened this issue Apr 30, 2023 · 11 comments · Fixed by #49208
Closed
1 task done

icon.svg is not included in standalone output #49009

darthmaim opened this issue Apr 30, 2023 · 11 comments · Fixed by #49208
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. Metadata Related to Next.js' Metadata API. Output (export/standalone) Related to the the output option in `next.config.js`.

Comments

@darthmaim
Copy link
Contributor

Verify canary release

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

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023
    Binaries:
      Node: 18.11.0
      npm: 8.19.2
      Yarn: 1.22.19
      pnpm: 7.28.0
    Relevant packages:
      next: 13.3.3-canary.0
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

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

App directory (appDir: true), Standalone mode (output: "standalone")

Link to the code that reproduces this issue

https://github.com/darthmaim/reproduction-next-icon-standalone

To Reproduce

  1. checkout https://github.com/darthmaim/reproduction-next-icon-standalone
  2. verify manually
    1. npm i
    2. npm run build
    3. Open .next/standalone/.next/server/app/icon.svg/route.js and see it contains an absolute path to the source file
  3. verify with with-docker example:
    1. docker build -t reproduction-next-icon-standalone .
    2. docker run -p 3000:3000 reproduction-next-icon-standalone
    3. Open http://localhost:3000/, see there is no favicon
    4. Inspect source, find <link rel="icon" ... in the head and open its url in a new tab
    5. See "Internal Server Error"
    6. See Error: ENOENT: no such file or directory, open '/app/app/icon.svg' in docker log

Describe the Bug

When using icon.svg (other meta files might be affected as well) they are not included in the standalone output. Instead the standalone output references absolute paths in the source directory.

This works when running the standalone build on the same machine that build it, but breaks if the standalone build is for example included in docker.

The reproduction includes the Dockerfile from the with-docker example to visualize this.

Expected Behavior

The standalone output should contain the icon.svg file and the icon.svg/route should not include an absolute path to the source directory.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

standalone

@darthmaim darthmaim added the bug Issue was opened via the bug report template. label Apr 30, 2023
@github-actions github-actions bot added area: app App directory (appDir: true) Output (export/standalone) Related to the the output option in `next.config.js`. labels Apr 30, 2023
@advancingu
Copy link

Seeing the same issue with a PNG file (i.e. app/icon.png gets turned into /app/app/icon.png on the web).

@advancingu
Copy link

Probably a duplicate of #48962.

@sFritsch09
Copy link

#49107

@huozhi huozhi added the Metadata Related to Next.js' Metadata API. label May 4, 2023
@huozhi
Copy link
Member

huozhi commented May 4, 2023

Close it as duplicate of #48962, let's track there 🙏

@huozhi huozhi closed this as completed May 4, 2023
@huozhi
Copy link
Member

huozhi commented May 4, 2023

For your reproduction you also need to include .next/server/app into docker so that prerendered filesystem cache can be HIT

@darthmaim
Copy link
Contributor Author

For your reproduction you also need to include .next/server/app into docker so that prerendered filesystem cache can be HIT

Then the with-docker example should be modified, because I took that Dockerfile without modifications.

@huozhi
Copy link
Member

huozhi commented May 4, 2023

Identified the issue that the cache missing is caused by other reason, fixing

feedthejim pushed a commit that referenced this issue May 4, 2023
Fixes #48962
Fixes #49009
Fixes #49107 

### Why

For standalone mode the `fs.readFile` is executed for `route.js` when
the module is loaded, then the fs operation aginst the wrong file path
will break the proper module loading, then it fallbacks to `/_error`
module.

### What

We move the fs read operation to the first get then cache the buffer in
the module level variable, so that `fs.readFile` won't be executed. As
we already have prerender cache, the meta/body fs cache will be HIT and
served
@huozhi
Copy link
Member

huozhi commented May 4, 2023

We got a fix out in 13.4, upgrade it to check it out if resolves the issue 🙏

@darthmaim
Copy link
Contributor Author

Confirmed working now, thanks for the fix ❤️

@huozhi
Copy link
Member

huozhi commented May 5, 2023

Thank you for the detailed writing for reproduction steps, was super helpful to me when I investigated with docker 🙏

@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2023

This closed issue has been automatically locked because it had no new activity for a month. 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 locked as resolved and limited conversation to collaborators Jun 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. Metadata Related to Next.js' Metadata API. Output (export/standalone) Related to the the output option in `next.config.js`.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants