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

Edge Chunks are not copied over from original .next/server to .next in .next/standalone/server #42751

Closed
1 task done
DuCanhGH opened this issue Nov 10, 2022 · 9 comments · Fixed by #43326
Closed
1 task done
Labels
bug Issue was opened via the bug report template.

Comments

@DuCanhGH
Copy link
Contributor

DuCanhGH commented Nov 10, 2022

Verify canary release

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

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro for Workstations
Binaries:
  Node: 18.12.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 13.0.3-canary.3
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

Chrome 107.0.5304.89 / Firefox Developer Edition 107.0b9

How are you deploying your application? (if relevant)

Fly.io (https://reproduction-next-standalone-edge-chunks.fly.dev/ //removed because of the 2-app limit set by Fly.io)

Describe the Bug

When I used output: "standalone" in next.config.js and deployed it on Fly.io using Dockerfile (same as the one in examples/with-docker) and then went to /api/hello, instead of seeing the expected og image generated with vercel/og, I saw an error like this "Internal Server Error". When I checked Fly.io's log it turned out that there's no such file as '.next/server/edge-chunks/wasm_5b50c798761dc0131e9ebe945031077e8a02633b.wasm'.
image
So I tried building the app locally it turned out that there exists files with the name 'wasm_long hash.wasm' in the root .next's ./server/edge-chunks, but that edge-chunks folder wasn't copied into the .next/server folder in .next/standalone.

Oh, and upon building it locally, I also saw this
image
I don't know if it may be related to the issue, so here it is.

Thank you :)

Expected Behavior

Everything should works normally as if in next dev or production without standalone mode.

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://github.com/DuCanhGH/no-edge-chunks-in-next-standalone

To Reproduce

To reproduce you have to:

  • Deploy the repository on somewhere that supports Dockerfile, or:
  • Clone the repository.
  • Run pnpm i.
  • Run pnpm build.
  • Run node .next/standalone/server.js, if this doesn't work then you may have to use Docker to build an image and start it (this is the case for me on Windows).
  • Go to /api/hello.
@DuCanhGH DuCanhGH added the bug Issue was opened via the bug report template. label Nov 10, 2022
@liho00
Copy link

liho00 commented Nov 11, 2022

same issue

@jandolezal71
Copy link

jandolezal71 commented Nov 27, 2022

Same, got root page in app directory, but got 404.

nextjs: `13.0.5`
module.exports = {
	poweredByHeader: false,
	reactStrictMode: true,
	swcMinify: true,
	experimental: {
		appDir: true,
	},
	output: 'standalone',
};
next build 

cp -r ./.next/standalone ./app
cp -r ./.next/static ./app/.next
cp -r ./public ./app/.next

node ./app/server.js

Page will throw 404.

When i will try to copy manualy folders chunks and app, it works.

cp -r ./.next/server ./app/.next/server
cp -r ./.next/chunks ./app/.next/server

@DuCanhGH
Copy link
Contributor Author

DuCanhGH commented Nov 28, 2022

@jandolezal71 have you tested it with the latest canary build? Support for app/ dir in output: "standalone" arrived a few days ago, so you shouldn't see 404 error for urls from app/ anymore.

@jandolezal71
Copy link

@jandolezal71 have you tested it with the latest canary build? Support for app/ dir in output: "standalone" arrived a few days ago, so you shouldn't see 404 error for urls from app/ anymore.

Hi,

cool, with 13.0.6-canary1 it works now, BUT, static somehow stopped working :-) After next build, i will copy static directory into standalone/.next directory, besides server directory, but static are returning 404.

image

image

@DuCanhGH
Copy link
Contributor Author

@jandolezal71 that's kinda weird. I'm not seeing that issue for some reason. Have you tried restarting the server? Maybe you copied static/ into .next/standalone/.next after you had launched the server? In that case, you'd have to restart the server for it to recognize the static/ dir and serve it.

@jandolezal71
Copy link

Ah, 🤦 i did not. Thank you, that's resolved then.

@cstenglein
Copy link

cstenglein commented Nov 29, 2022

Can confirm this is an issue with 13.0.5 & an edge api route I'm using.

I'm using the OG image generation, which doesn't work with 13.0.5: https://github.com/cstenglein/manysats/blob/main/pages/api/og.tsx

With 13.0.6-canary.2 the edge API route is working again, but building the application still generates the following warning:

warn  - Failed to copy traced files for /manysats/.next/server/pages/api/og.js [Error: ENOENT: no such file or directory, open '/manysats/.next/server/pages/api/og.js.nft.json'] {

@DuCanhGH
Copy link
Contributor Author

@cstenglein I've opened a PR on that warning, see #43326 :) Should be gone after that one hopefully gets approved

ijjk added a commit that referenced this issue Dec 1, 2022
…iles with middleware-manifest.json (#43326)

<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

fixes: #41395
fixes: #42751.
This PR is a follow-up PR of [PR
43304](#43304).

This fix works by checking if the page is listed in
middleware-manifest.json's functions, if true then skip the
handleTraceFiles process. This also fixes the two issues aforementioned
by copying files listed in middleware-manifest.json for those pages.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
@github-actions
Copy link
Contributor

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 Dec 31, 2022
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants