hemerajs / hemera

🔬 Writing reliable & fault-tolerant microservices in Node.js https://hemerajs.github.io/hemera/
MIT License
806 stars 70 forks source link

Provided examples for promises do not work #128

Closed remipassmoilesel closed 7 years ago

remipassmoilesel commented 7 years ago

Hi ! Thanks for Hemera it is a great tool, but some examples do not work.

Description

Provided examples do not work. If you try examples provided with promises here: https://github.com/hemerajs/hemera#what-hemera-code-looks-like https://github.com/hemerajs/hemera/blob/master/examples/basic/async-await.js

Every time I obtain these errors:

[2017-07-28T08:44:32.701Z] INFO (hemera-CompanionCube-ab2674533b024d95b6b2bd1f31a473ab/26558 on CompanionCube): Connected!
[2017-07-28T08:44:34.712Z] ERROR (hemera-CompanionCube-ab2674533b024d95b6b2bd1f31a473ab/26558 on CompanionCube): Timeout
    TimeoutError
        at timeoutHandler (/home/remipassmoilesel/projects/poc-microservice-communications/node_modules/nats-hemera/lib/index.js:1283:21)
        at Timeout._onTimeout (/home/remipassmoilesel/projects/poc-microservice-communications/node_modules/nats/lib/nats.js:1242:5)
        at ontimeout (timers.js:469:11)
        at tryOnTimeout (timers.js:304:5)
        at Timer.listOnTimeout (timers.js:264:5)
[2017-07-28T08:44:34.713Z] ERROR (hemera-CompanionCube-ab2674533b024d95b6b2bd1f31a473ab/26558 on CompanionCube): Timeout
    TimeoutError
        at timeoutHandler (/home/remipassmoilesel/projects/poc-microservice-communications/node_modules/nats-hemera/lib/index.js:1283:21)
        at Timeout._onTimeout (/home/remipassmoilesel/projects/poc-microservice-communications/node_modules/nats/lib/nats.js:1242:5)
        at ontimeout (timers.js:469:11)
        at tryOnTimeout (timers.js:304:5)
        at Timer.listOnTimeout (timers.js:264:5)
(node:26558) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TimeoutError: Timeout
(node:26558) [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.
^C[2017-07-28T08:54:32.016Z] FATAL (hemera-CompanionCube-ab2674533b024d95b6b2bd1f31a473ab/26558 on CompanionCube): process exited
    signal: "SIGINT"
[2017-07-28T08:54:32.018Z] INFO (hemera-CompanionCube-ab2674533b024d95b6b2bd1f31a473ab/26558 on CompanionCube): Gracefully shutdown

Steps to Reproduce

  1. Start NATS
  2. Past examples
  3. Install npm packages
  4. Run examples
  5. See errors

Context

Your Environment

StarpTech commented 7 years ago

Hi @rualatngua which hemera version are you using? Please double check it. The code looks good to me. At the moment I can't test it. I will investigate in few days but thanks for reporting.

remipassmoilesel commented 7 years ago

I took the package from npm repo. Here is a sample from my package.json:

{
  "dependencies": {
    ...
    "hemera": "0.0.5",
    "hemera-joi": "^1.1.13",
    "hemera-rabbitmq": "0.0.38",
    "nats": "^0.7.20",
    "nats-hemera": "^1.3.23",
    ...
  },
  "devDependencies": {
    "@types/bluebird": "^3.5.8",
    "@types/colors": "^1.1.3",
    "@types/lodash": "^4.14.71",
    "@types/node": "^8.0.15",
    "typescript": "^2.4.2"
  },
  ...
}

I tried a million time at least :)

StarpTech commented 7 years ago

Hi @remipassmoilesel examples\basic\async-await.js works fine:

node .\examples\basic\async-await.js
[2017-07-29T15:23:04.283Z] INFO (hemera-starptech-ca429596ff6643fbac282a4106dac73f/15336 on starptech): Connected!
[2017-07-29T15:23:04.287Z] INFO (hemera-starptech-ca429596ff6643fbac282a4106dac73f/15336 on starptech): ADD - ADDED
    topic: "math"
    cmd: "add"
test

and https://github.com/hemerajs/hemera#what-hemera-code-looks-like works too

[2017-07-29T15:22:08.997Z] INFO (hemera-starptech-e15570baf9c44316bd4b5e3bcc5f964c/2056 on starptech): hemera-joi PLUGIN - ADDED!
[2017-07-29T15:22:09.004Z] INFO (hemera-starptech-e15570baf9c44316bd4b5e3bcc5f964c/2056 on starptech): Connected!
[2017-07-29T15:22:09.007Z] INFO (hemera-starptech-e15570baf9c44316bd4b5e3bcc5f964c/2056 on starptech): ADD - ADDED
    topic: "math"
    cmd: "add"
[2017-07-29T15:22:09.017Z] INFO (hemera-starptech-e15570baf9c44316bd4b5e3bcc5f964c/2056 on starptech):
    0: 40
    1: 70

Hemera: 1.3.23 Hemera-Joi: 1.1.13 Nats: 0.7.20

I saw that you have a dependency called hemera this is invalid I think thats a typo right? Could you please post your code examples that reproduce the timeout? Thanks

StarpTech commented 7 years ago

@remipassmoilesel any feedback?

remipassmoilesel commented 7 years ago

I tried another time but this time on my personnal computer and it work :) Sorry for the noise. Maybe it is a platform specific problem but I am very surprised about that, I tried many different ways.

If I find something interesting I will tell you back.