vulcainjs / vulcain-corejs

Microservice framework for nodejs
https://vulcainjs.github.io
Apache License 2.0
11 stars 3 forks source link

Unhandled promise rejection from Prometheus #29

Closed mrik974 closed 7 years ago

mrik974 commented 7 years ago

Hi, We have a long timed request in one of our vulcain service's QueryHandler. It is mainly used to retrieve various information and send it back to the user at once. Sometimes it throws an error in the logs and gets stuck, leading to a 504 Gateway Timeout from our proxy.

Here's the error (there's no other stack trace about it)

(node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Added label "uri" is not included in initial labelset: [ 'service', 'version' ]

I've lurked a bit into the node_modules to find which was in cause, and I found the error being in prom-client, more specifically in the validation.js file. I then looked at where in your code you're using this library. It looks like this file is the only one that's really using it. I don't know what's going on, but all I can say is that it doesn't happen every time. Most of the times, the handler was throwing a 500 error at the previous request. Maybe it is duration related too. I don't know if it'll help.

mrik974 commented 7 years ago

OK, I have more information about it. It appears that the code in the QueryHandler was making direct calls to a Service that could fail. The problem was on our code side. Since I've put the service calls in Commands, it works better. However, it shows that an unhandled promise rejection makes the Handler lose its consistency.

malain commented 7 years ago

I cannot reproduce this error but i have published a new version to fix another exception with promotheus.