Skip to content

Force close process after build / prepare commands #193

Closed
nitrojs/nitro
#2287
@enkot

Description

@enkot

Environment

  • Operating System: Linux
  • Node Version: v16.20.0
  • Nuxt Version: 3.7.0
  • CLI Version: 3.7.2
  • Nitro Version: 2.6.2
  • Package Manager: npm@9.4.2
  • Builder: -
  • User Config: modules, routeRules, hooks
  • Runtime Modules: @nuxt/devtools@0.8.2
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-c8qlr3?file=server%2Fplugins%2Ftest.ts

Describe the bug

If we add the page to routeRules (prerender: true) and start some timer/listener in the Nitro plugin, the process does not close after the build.
Also nitro.hooks.hook('close', () => {}) will never be called.

Additional context

It was working fine on Nuxt 3.6.5.

Temporary workaround (UPDATED):

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

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions