dthree / dthree/vorpal

Bug: Rejected promises are handled incorrectly (process returns zero status code)

Open
#283 1 comment 8 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.6k
Forks
278
PR merge metrics
No merged PRs in 30d

Description

Hello!

Thank you for this great library!

However, the rejected promises, which are returned from the commands are handled incorrectly.

I've created a simple repository to demonstrate the issue:
https://github.com/slavafomin/vorpal-promise-rejection-issue

Here's the minimal example:

```js
const vorpal = require('vorpal')();

vorpal
.command('test-callback')
.action((args, callback) =>
setTimeout(() =>
callback(new Error('Something bad happened...')), 500
)
)
;

vorpal
.command('test-promise')
.action(args =>
new Promise((resolve, reject) =>
setTimeout(() =>
reject(new Error('Something bad happened...')), 500
)
)
)
;

// vorpal.parse(['', '', 'test-callback']);

vorpal.parse(['', '', 'test-promise']);
```

When callback is used, then error is logged to the console and process exists with non-zero status code. However, when rejected promise is returned, then the `Unhandled promise rejection` warning is generated and process exits with zero code (which is a bug).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.