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

not-found build hangs with NODE_ENV=test #53083

Closed
1 task done
karlhorky opened this issue Jul 23, 2023 · 2 comments · Fixed by #53106
Closed
1 task done

not-found build hangs with NODE_ENV=test #53083

karlhorky opened this issue Jul 23, 2023 · 2 comments · Fixed by #53106
Labels
bug Issue was opened via the bug report template. locked

Comments

@karlhorky
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: #22 SMP Tue Jan 10 18:39:00 UTC 2023
    Binaries:
      Node: 16.17.0
      npm: 8.15.0
      Yarn: 1.22.19
      pnpm: 7.1.0
    Relevant Packages:
      next: 13.4.12
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 4.9.5
    Next.js Config:
      output: N/A

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

App Router

Link to the code that reproduces this issue or a replay of the bug

https://codesandbox.io/p/sandbox/reverent-matan-pvw8wk?file=%2F.codesandbox%2Ftasks.json%3A10%2C4

To Reproduce

  1. Visit the CodeSandbox link above, which uses NODE_ENV=test next build
  2. The build-and-start task, which starts automatically, hangs and never completes💥 (process exits after 3 retries)
$ next build
- info Creating an optimized production build  
- info Compiled successfully
- info Linting and checking validity of types  
- info Collecting page data  
- warn Restarted static page generation for /_not-found because it took more than 60 seconds
- warn See more info here https://nextjs.org/docs/messages/static-page-generation-timeout
- warn Restarted static page generation for /_not-found because it took more than 60 seconds

> Build error occurred
Error: Static page generation for /_not-found is still timing out after 3 attempts. See more info here https://nextjs.org/docs/messages/static-page-generation-timeout
    at onRestart (/project/sandbox/node_modules/next/dist/build/index.js:697:39)
    at Worker.exportPage (/project/sandbox/node_modules/next/dist/lib/worker.js:88:40)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /project/sandbox/node_modules/next/dist/export/index.js:519:32
    at async Span.traceAsyncFn (/project/sandbox/node_modules/next/dist/trace/trace.js:103:20)
    at async Promise.all (index 2)
    at async /project/sandbox/node_modules/next/dist/export/index.js:510:9
    at async Span.traceAsyncFn (/project/sandbox/node_modules/next/dist/trace/trace.js:103:20)
    at async /project/sandbox/node_modules/next/dist/build/index.js:1579:21
    at async Span.traceAsyncFn (/project/sandbox/node_modules/next/dist/trace/trace.js:103:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Screenshot 2023-07-23 at 19 03 30

This may have been caused by the following PR by @huozhi, reviewed by @ijjk :

Describe the Bug

The not-found page build hangs when using NODE_ENV=test

This behavior is not present when using next@13.4.11

This may have been caused by the following PR by @huozhi, reviewed by @ijjk :

Related issue (not exactly a dupe): #53082

Expected Behavior

The not-found page build should succeed when using NODE_ENV=test

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@karlhorky karlhorky added the bug Issue was opened via the bug report template. label Jul 23, 2023
@kodiakhq kodiakhq bot closed this as completed in #53106 Jul 24, 2023
kodiakhq bot pushed a commit that referenced this issue Jul 24, 2023
### Why

In #52985 the not found solution introduces `NODE_ENV` to determine if it his the not found boundary and should render the not found, as in the next build mode, we have `/_not-found` as a special route which has a empty parallel route, but in next dev mode so far it his the `parallel-default-route`. This could dependend on the `NODE_ENV` passing to next server but not necessarily.

### What

Fixes #53082
Fixes #53083 

### How

When server actions `not-found` hits, now we create a new loader tree based on the previous one, including `layout` and other components but not the children parallel routes

For production case, to make the rendering independent from the `NODE_ENV`, we're using original pathname to check if it's `/_not-found` to determine if it's production build 404 page

To support replace the loader tree of action, did a little refactor that passing down the loader tree from top level to `bodyResult`. Then we can change the loader tree itself before rendering, in short, we tweak it from original tree to one for not-found case, so server actions could render it properly
@karlhorky
Copy link
Contributor Author

karlhorky commented Jul 25, 2023

Thanks for #53106 @huozhi and @ijjk 🙌

I can confirm that next@13.4.13-canary.0 fixes the problem:

CodeSandbox: https://codesandbox.io/p/sandbox/awesome-rosalind-ntzj8k?file=%2Fpackage.json%3A13%2C23

Screenshot 2023-07-25 at 07 04 32

@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 Aug 16, 2023
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant