Generator-jhipster: --skip-server does not log error message on failure

Created on 13 Dec 2019  路  11Comments  路  Source: jhipster/generator-jhipster

Overview of the issue

Running jhipster --skip-server only prompts for the baseName of the application, then exits silently without any message. Previously (v6.5.1 and before), it would exit with an error message:

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: When using skip-server flag, you must pass a database option and authentication type using --db and --auth flags
Motivation for or Use Case

Error messages should display as expected

Reproduce the error

Run jhipster --skip-server and answer the baseName prompt, it will then exit without the expected error message

Suggest a Fix

I have not looked into it. Did we change error handling since the last release? Or maybe something related to yeoman?

Git bisect shows this issue first appeared after #10727

75c31ed5a5fc5b2df024a6508f415423fa670535 is the first bad commit
commit 75c31ed5a5fc5b2df024a6508f415423fa670535
Author: Marcelo Boveto Shima <[email protected]>
Date:   Mon Nov 4 16:32:33 2019 -0200

    Exit import-jdl with status from the forked process.

:040000 040000 6d924f61565ba9e31d779aed3956cd9093afc66e 8751ab748e47c88ff97d71d6dec91a4837d8e347 M  cli
JHipster Version(s)

Reprouced with Master
Error message shows correctly on v6.5.1

Browsers and Operating System

Mac, Node LTS

  • [x] Checking this box is mandatory (this is just to show you read everything)
$$ bug-bounty $$ $100 area jhipster-internals

All 11 comments

Adding a bounty on this, as it's a bug

So I analyzed this issue and I think the following lines,

https://github.com/jhipster/generator-jhipster/blob/ba88f1424ddffd08589377a1dba9e432ceaa8a0b/cli/cli.js#L45-L47

have a problem. It tells node to end abruptly which is not necessary it seems (Refer: https://nodejs.org/api/process.html#process_process_exit_code). We can instead set the process.exitCode there. I've created a PR for this. Let me know if you guys agree with this. :smile:

cc: @mshima

Thank you @SudharakaP for finding this.
This makes getExitCode and setExitCode useless.
https://github.com/jhipster/generator-jhipster/pull/10946

I think blueprints has the same problem with:
https://github.com/jhipster/generator-jhipster/blob/e362242b0f750f04867fb2e087f1911af84e548b/cli/run-yeoman-process.js#L31-L33

@mshima : Thanks for cleaning it up. Please feel free to claim the bug bounty as you did most work. :smile:

I've done another PR to remove all explicit calls to process exit. Let me know if you guys see any issues. :smile:

@SudharakaP : The bounty is yours. I introduced the bug (https://github.com/jhipster/generator-jhipster/pull/10727) at first place :disappointed:.

That PR fixed a bug were IT tests was failing at E2E step, but import-jdl was to blame.

@pascalgrimaud I think https://github.com/jhipster/generator-jhipster/pull/10948 is not safe.

log.error forces jhipster to quit. without process.exit() this will not happen.

@mshima : you know this part better than me. If you can fix it, it would be nice !

@pascalgrimaud : this is not a regression, so I think it should be reverted for 6.6.0.
This is not easy to test.

@pascalgrimaud @mshima : Sorry about that. Please feel free to merge the reversion (#10951) for now. Let me think of a way to handle this more cleanly. 馃

@SudharakaP : The bounty is yours. I introduced the bug (#10727) at first place 馃槥.

That PR fixed a bug were IT tests was failing at E2E step, but import-jdl was to blame.

@mshima : Since you are doing most of the process.exit bug fixes, I think we should at least split this bounty.

I am claiming half of it. Feel free to take the other half. 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SudharakaP picture SudharakaP  路  3Comments

Steven-Garcia picture Steven-Garcia  路  3Comments

SudharakaP picture SudharakaP  路  3Comments

chegola picture chegola  路  4Comments

RizziCR picture RizziCR  路  3Comments