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

SIGTERM and SIGINT exit codes should be non-zero #62906

Closed
jaysoo opened this issue Mar 5, 2024 · 1 comment · Fixed by #64871
Closed

SIGTERM and SIGINT exit codes should be non-zero #62906

jaysoo opened this issue Mar 5, 2024 · 1 comment · Fixed by #64871
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. locked

Comments

@jaysoo
Copy link
Contributor

jaysoo commented Mar 5, 2024

Link to the code that reproduces this issue

https://github.com/jaysoo/nx-next-cli-issue

To Reproduce

From the linked repo:

  1. Run the command npx nx build
  2. Kill the build process (Ctrl+C)
  3. Run npx nx build again

Current vs. Expected behavior

Expected:

Nx re-runs Next CLI

Actual:
Nx reads task from cache, but the .next folder is invalid.

This happens because the Next CLI exited with 0 in step (2), which tells Nx that the build successfully completed.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020
  Available memory (MB): 98304
  Available CPU cores: 12
Binaries:
  Node: 21.7.1
  npm: 10.5.0
  Yarn: 1.22.22
  pnpm: 8.15.7
Relevant Packages:
  next: 14.2.2 // Latest available version is detected (14.2.2).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

CLI (create-next-app)

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

This can affect other tooling, as demonstrated here with Turborepo that results in a bad cache. https://github.com/jaysoo/next-cli-signals

SIGTERM can happen in CI and Docker when process times out, or reaches memory limit.

@jaysoo jaysoo added the bug Issue was opened via the bug report template. label Mar 5, 2024
@github-actions github-actions bot added the create-next-app Related to our CLI tool for quickly starting a new Next.js application. label Mar 5, 2024
@ztanner ztanner closed this as completed in f771c6d Nov 4, 2024
stipsan pushed a commit to sanity-io/next.js that referenced this issue Nov 6, 2024
…#64871)

This PR updates the SIGTERM and SIGINT exit codes to 143 and 130
respectively. These updated codes are what other tooling, such as
Nx/Turborepo, expects when running commands that did not completely
successfully due to receiving SIGTERM and SIGINT.

For Nx, the SIGINT (e.g. `Ctrl+C`) causes a bad build cache. Both Nx and
Turborepo will have bad cache when SIGTERM is received, which can happen
in a CI environment if a job times out, runs out of memory, etc.

I have a [repo here](https://github.com/jaysoo/next-cli-signals) that
demonstrates the wrong behavior with Turborepo. By exiting with the
wrong code, it can result in bad cache in CI or Docker.

Closes: vercel#62906

---------

Co-authored-by: Sam Ko <[email protected]>
Co-authored-by: Zack Tanner <[email protected]>
Copy link
Contributor

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 locked as resolved and limited conversation to collaborators Nov 20, 2024
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. create-next-app Related to our CLI tool for quickly starting a new Next.js application. locked
Projects
None yet
1 participant