Closed esatterwhite closed 7 years ago
Hi, thanks for reporting I will investigate.
@esatterwhite I can't reproduce it. I tried:
hemera.add(
{
topic: 'profile',
cmd: 'get'
},
async function(req) {
throw new Error('test')
}
)
with this example https://github.com/hemerajs/hemera/blob/master/examples/monitoring/jaeger.js but the error is returned correctly. Please have in mind that errors that are thrown asynchronously are not able to catch.
ah, sorry I mis-spoke. The function doesn't throw, it calls the reject function from a promise. so more like
hemera.add(
{
topic: 'profile',
cmd: 'get'
},
async function(req) {
await someOp()
}
)
function someOp() {
return new Promise((resolve, reject) => {
const error = new Error('broke')
setImmediate(reject, err)
})
}
The problem isn't that the error isn't being handled. It is getting to this line and this.opentracing
is undefined
I can't reproduce it the error is logged and the process survived. Could you provide a full example?
const Hemera = require('hemera')
const nats = require('nats').connect()
const hemeraJaeger = require('hemera-jaeger')
const hemera = new Hemera(nats, {
logLevel: 'debug',
childLogger: true,
tag: 'math'
})
hemera.use(hemeraJaeger, {
serviceName: 'math'
})
hemera.ready(() => {
hemera.add(
{
topic: 'math',
cmd: 'add'
},
async function(req) {
await someOp()
}
)
function someOp() {
return new Promise((resolve, reject) => {
const error = new Error('broke')
setImmediate(reject, error)
})
}
hemera.act({
topic: 'math',
cmd: 'add'
}, function() {
})
})
Please also update to hemera 2.3.1
Ah, I found it!. I was running a script and calling hemera.act
with out wrapping it in the ready
callback. I think that fixes my problem.
user error 🥇
will the ready callback be executed immediately if hemera is ready
?
basically is it ok to call hemera.ready
more than once or if the ready event has already been triggered.
or do you only have 1 shot?
silly example, but this:
hemera.ready(() => {
hemera.ready(() => {
// will I ever get here?
})
})
Yes, the event is called once when nats and all plugins were initialized.
You can't listen to the ready event multiple times.
Can be closed ?
Yep. Thanks for your help
It looks like the caller doesn't have the
opentracing
object set onthis
in the error event handlersDescription
Steps to Reproduce
Example:
the handler looks like this
with out the
jaeger
pluging, it works just fine, the error is propagated back the caller. This also works fine with the jaeger plugin and there is no error.Expected Result
error is logged and sent to jaeger
Actual Result
error is throw and process crashes
Context
Your Environment