infeeeee / kimai2-cmd

Command line client for Kimai2, the open source, self-hosted time tracker
MIT License
24 stars 6 forks source link

Exceptions of stop of measurement(s) if currently no measurements are running #12

Closed ebroda closed 4 years ago

ebroda commented 4 years ago

Thank you for the nice cli. It works fine, but I just had an issue with the cli when no measurement is going on, but I want to stop it.

Situation: No measurement is currently runnning.

Situation A: Selecting "Stop all active measurements"

Expected: Message: "Currently no measurements were running." and return to menu, like at "List active measurements".

Result:

(node:1124) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
    at Promise (/snapshot/kimai2-cmd/kimai2-cmd.js:320:55)
    at new Promise (<anonymous>)
    at callKimaiStop (/snapshot/kimai2-cmd/kimai2-cmd.js:318:12)
    at kimaiList.then.res (/snapshot/kimai2-cmd/kimai2-cmd.js:300:28)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:1124) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:1124) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

and I need to restart the tool.

Situation B: Select "Stop an active measurement". This shows no running measurments, but allows to select/enter which leads to an error:

Expected: same as above.

Result:

(node:1136) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'value' of undefined
    at ListPrompt.getCurrentValue (/snapshot/kimai2-cmd/node_modules/inquirer/lib/prompts/list.js:121:53)
    at MapSubscriber._next (/snapshot/kimai2-cmd/node_modules/rxjs/internal/operators/map.js:0:0)
    at MapSubscriber.Subscriber.next (/snapshot/kimai2-cmd/node_modules/rxjs/internal/Subscriber.js:66:18)
    at TakeSubscriber._next (/snapshot/kimai2-cmd/node_modules/rxjs/internal/operators/take.js:0:0)
    at TakeSubscriber.Subscriber.next (/snapshot/kimai2-cmd/node_modules/rxjs/internal/Subscriber.js:66:18)
    at Interface.handler (/snapshot/kimai2-cmd/node_modules/rxjs/internal/observable/fromEvent.js:22:28)
    at Interface.emit (events.js:194:15)
    at Interface._onLine (readline.js:290:10)
    at Interface._line (readline.js:638:8)
    at Interface._ttyWrite (readline.js:919:14)
(node:1136) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

and I need to restart the tool.

infeeeee commented 4 years ago

Thank you for the bug report! Fixed it in this commit: 49d9752b52b7324ab2605c09579c1a8faa87a308 I will create a new release and update builds soon!