nestjs / nest-cli

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

Exit code does not inherit the exit code of running the app: nest start #1044

Closed loklaan closed 3 years ago

loklaan commented 3 years ago

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behaviour

Similar to what was reported in #423, the next start exists with a code 0 regardless of what the underlying child process exits with.

Expected behaviour

The nest start command should exit with the code given by the child process.

Minimal reproduction of the problem with instructions

See loklaan/repro-nestcli__nest-start-exit-code

What is the motivation / use case for changing the behavior?

Have things like CI/CD pipelines function correctly when using nest start.

Worth mentioning that a workaround for this is as follows:

yarn nest build
node ./dist/main.js 

I'm guessing this is what everyone does right now. Or in most cases the dist in managed by pm2 etc.

Environment

MacOS / Linux (Ubuntu)

loklaan commented 3 years ago

Am happy to get a PR together for this if this is in fact a bug!

jmcdo29 commented 3 years ago

Would you mind putting those steps into a public repository that can be cloned?

loklaan commented 3 years ago

@jmcdo29 No worries - added to OP

jmcdo29 commented 3 years ago

I can definitely reproduce it, and it does seem to be coming from the CLI. Everything under the hood ends up going through commander, but if I remember right, process.exit(1) should bubble up through there, so it seems something else is at play.

kamilmysliwiec commented 3 years ago

Fixed in this commit https://github.com/nestjs/nest-cli/commit/dd2217179ce701d6c6005dc342458ab1ccade216 and published as 7.5.5

loklaan commented 3 years ago

Much appreciated @kamilmysliwiec 😍