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

Build not exiting on errors inside Suspense #52792

Closed
1 task done
roch-numbered opened this issue Jul 17, 2023 · 2 comments
Closed
1 task done

Build not exiting on errors inside Suspense #52792

roch-numbered opened this issue Jul 17, 2023 · 2 comments
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.

Comments

@roch-numbered
Copy link

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.12.0
      npm: 9.7.1
      Yarn: 1.22.19
      pnpm: 8.6.8
    Relevant Packages:
      next: 13.4.10-canary.8
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: N/A
    Next.js Config:
      output: N/A

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

No response

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

https://github.com/roch-numbered/next-build-with-suspense

To Reproduce

  1. Run npm run build.
  2. The task outputs an error info Generating static pages (0/3)TypeError:.
  3. The build passes.

Note: I intentionally added an error in the code to make this bug testable.

Describe the Bug

The build passes instead of exiting.

Expected Behavior

When a Next.js app is built, errors should prevent the task to finalize the build and exit the process.

It's important to note that removing the <Suspense> boundary makes the build process to crash. Also, it seems to required a _app.tsx file, I first tried to use <Suspense /> inside the pages/index.tsx file but the bug wasn't reproducible.

Intentional code error

As mentioned previously, the code is intentionally not working in order to demonstrate my issue.

To fully describe my use case, imagine that title variable is an array coming from an external source (CMS, API etc.). If the value is changed to a string (or whatever other type), the page generation (or revalidation) should crash and not pass (which isn't currently the case).


Personal understanding

I may be wrong about the use of Suspense in this context.

  1. Is it normal that the build process passes?
  2. Should it be used with App Router and React Server Component only to avoid this?

ISR

A last note/question on revalidation and ISR, from the documentation, I'm seeing this:

When a request is made to a page that was pre-rendered at build time, it will initially show the cached page.

  • Any requests to the page after the initial request and before 10 seconds are also cached and instantaneous.
  • After the 10-second window, the next request will still show the cached (stale) page
  • Next.js triggers a regeneration of the page in the background.
  • Once the page generates successfully, Next.js will invalidate the cache and show the updated page. If the background regeneration fails, the old page would still be unaltered.

From a previous experience, I've faced an issue where a field value has changed (let's say from an array to a string) between the build and the revalidation and made the whole app to crash. While the first build was well working, Next.js still promoted to front-end a broken revalidated version of the page.

My question here may sound a bit off topic but is it the expected behavior of Next.js? Or is it related to this build-not-exiting issue?
Because from what I see on the documentation (Error handling and revalidation):

If there is an error inside getStaticProps when handling background regeneration

Does "background regeneration failing" only mention errors happening inside getStaticProps or also includes render errors?

Note: If you prefer me to discuss that second topic on a discussion, I can split this into two parts, it just feels connected to me.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Vercel

@roch-numbered roch-numbered added the bug Issue was opened via the bug report template. label Jul 17, 2023
@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 17, 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 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.
Projects
None yet
Development

No branches or pull requests

2 participants