nestjs / nest-cli

CLI tool for Nest applications 🍹
https://nestjs.com
Other
1.95k stars 390 forks source link

Using Webpack Compiler and watchAssets is true, nest start's process can't be stopped from entry file. #2303

Closed tkow closed 11 months ago

tkow commented 12 months ago

Is there an existing issue for this?

Current behavior

If we use nest webpack compiler and watchAssets flag is true, we can't exit a process created by nest start command because watchAssets listener is separated from bootstrap process. In the result, It's uncomfortable to use nest as command line tools using webpack, given if like nest-commander.

See: ( https://github.com/tkow/nest-watch-assets-demo/blob/master/src/main.ts )

Minimum reproduction code

https://github.com/tkow/nest-watch-assets-demo

Steps to reproduce

  1. pnpm i
  2. npx nest start -- hello
  3. The process isn't exited unless you send signal INT

Expected behavior

When process.exit() calls from somewhere of entry files the nest start process should stop.

Package version

10.0.1

NestJS version

10.0.1

Node.js version

18.15.0

In which operating systems have you tested?

Other

I already suggest a way to fix this bug in the PR. Also chokidar listener can't listen to complete all copied processes. So if watchAssets: false specified, I think its' better that nest's logic fallback to sync process and I did in it.

kamilmysliwiec commented 11 months ago

Let's track this here https://github.com/nestjs/nest-cli/pull/2293