Hapi server emitted a log event tagged error


We are getting a lot of "hapi server emitted a log event tagged error" with a hapi server.

Any clue? Thanks very much, best regards


Hi Javier,

The Node.js APM agent will capture an error for any hapi server.log(tags, data) call where "error" is one of the tags. If the logged data field is neither an Error instance nor a string, the captured error will be given a fallback message "hapi server emitted a log event tagged error".

If it helps, the data passed to server.log(['error'], data) is included in the capture error in custom context, which should be visible in the "Metadata" tab:

Screen Shot 2021-05-04 at 12.18.54 PM

At least for me (relatively new to hapi), I don't think that is very obvious, so I've opened hapi instrumentation capturing of `server.log(['error'], ...)` is obscure · Issue #2071 · elastic/apm-agent-nodejs · GitHub to look into improving the experience here.

Thanks for bringing this up.

Thanks Trent,

I see, in the metadata I can see the capture error:

Best regards,