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

Production server doesn't stop with preset node-cluster #23723

Closed
Cheaterman opened this issue Oct 17, 2023 · 8 comments
Closed

Production server doesn't stop with preset node-cluster #23723

Cheaterman opened this issue Oct 17, 2023 · 8 comments

Comments

@Cheaterman
Copy link

Environment

cheaterman@cmans-laptop ~/Dev/fluxt/frontend main @ npx nuxi info
Working directory: /home/cheaterman/Dev/fluxt/frontend                                                                                                                                                    16:13:48
Nuxt project info: (copied to clipboard)                                                                                                                                                                  16:13:48

------------------------------
- Operating System: Linux
- Node Version:     v20.6.1
- Nuxt Version:     3.7.4
- CLI Version:      3.9.0
- Nitro Version:    2.6.3
- Package Manager:  [email protected]
- Builder:          -
- User Config:      devtools
- Runtime Modules:  -
- Build Modules:    -
------------------------------

👉 Report an issue: https://github.com/nuxt/nuxt/issues/new                                                                                                                                               16:13:48

👉 Suggest an improvement: https://github.com/nuxt/nuxt/discussions/new

👉 Read documentation: https://nuxt.com

cheaterman@cmans-laptop ~/Dev/fluxt/frontend main @ docker compose run --rm frontend npx nuxi info
Working directory: /home/node                                                                                                                                                                           4:14:01 PM
Nuxt project info:                                                                                                                                                                                      4:14:01 PM

------------------------------
- Operating System: Linux
- Node Version:     v18.18.2
- Nuxt Version:     3.7.4
- CLI Version:      3.9.0
- Nitro Version:    2.6.3
- Package Manager:  [email protected]
- Builder:          -
- User Config:      devtools
- Runtime Modules:  -
- Build Modules:    -
------------------------------

👉 Report an issue: https://github.com/nuxt/nuxt/issues/new                                                                                                                                             4:14:01 PM

👉 Suggest an improvement: https://github.com/nuxt/nuxt/discussions/new

👉 Read documentation: https://nuxt.com

Reproduction

  • Create a new Nuxt3 app with the default NuxtWelcome in app.vue
  • Build it making sure you're using NITRO_PRESET=node-cluster : NITRO_PRESET=node-cluster pnpm build
  • Serve it: node .output/server/index.mjs
  • Attempt to kill it non-interactively (ie, do not use ^C in shell) : pkill -f 'node .output' -TERM (SIGINT works too)
  • Notice that it takes two attempts (the way I originally noticed is because docker takes 10s to shut down, I suspect hitting the eventual SIGKILL timeout)

Describe the bug

One would expect production server to stop instantly at the first SIGINT/SIGTERM, instead it either takes two or needs a SIGKILL.

Additional context

  • This only happens with node cluster preset.
  • Using NITRO_SHUTDOWN does not help.
  • This does not happen with dev server.

Logs

No response

Copy link
Member

Would you confirm i f this happens with nitro alone, and if so raise an issue there? 🙏

@danielroe danielroe added the nitro label Oct 17, 2023 — with Volta.net
@pi0
Copy link
Member

pi0 commented Oct 17, 2023

Consider nitro server hase a graceful shutdown mechanism. If a request is pending for some reason or an active resource like DB connection hanging, this can happen regardless using nuxt or not.

Regardless i would be happy to help finding a solution also here if you can make a runnable reproduction. Nuxt is okay too 👍🏼

@github-actions
Copy link
Contributor

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz
👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@Cheaterman
Copy link
Author

Consider nitro server hase a graceful shutdown mechanism. If a request is pending for some reason or an active resource like DB connection hanging, this can happen regardless using nuxt or not.

Regardless i would be happy to help finding a solution also here if you can make a runnable reproduction. Nuxt is okay too 👍🏼

Yes, I noticed the graceful shutdown mechanism, that's why I mentioned Using NITRO_SHUTDOWN does not help.. Other than that I'd be more than happy to make a pure-Nitro reproduction and raise the issue there, however I'm completely unsure how to use Nitro outside of Nuxt, sorry!

@Mateleo
Copy link

Mateleo commented Oct 20, 2023

Yes I have exactly the same issue when deploying Nuxt
image

@pi0
Copy link
Member

pi0 commented Oct 20, 2023

@Cheaterman If you can make a Nuxt reproduction, that would also work!


@Mateleo Thanks for sharing. If your "build step" like the above fails, it is probably because of an unclosed handler made by a module or during the prerender process (from screenshot above I cannot tell). Here is the more relevant issue: nuxt/cli#193

@Mateleo
Copy link

Mateleo commented Oct 20, 2023

@pi0 You were right, it's the same issue : nuxt/cli#193

Temporary workaround

export default defineNuxtConfig({
  hooks: {
    close: (nuxt) => {
      if (!nuxt.options._prepare)
        process.exit()
    }
  }
})

@danielroe
Copy link
Member

Let's track in nuxt/cli#193 in that case.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants