Non-Error exception captured with keys: _abort, _raw, body, bodyUsed, headers…

Hello!

I’m using the Sentry node client (v4.1.1) and I’m trying to log server errors using hapi.js. In the catch block of my try/catch, I call captureException and send the error off to Sentry.

When testing locally, this works as expected. I tested causing a TypeError and the correct error propagated through (including the stack trace and line numbers).

When running on prod, it is not working like that. I don’t see any stack trace or any helpful information and it says “Non-Error exception captured with keys: _abort, _raw, body, bodyUsed, headers….”.

After doing a lot of research, most people were saying the type of the object is not an error. However, I confirmed it is. Here’s what I think is happening (any I’m not sure how to fix it). The error is happening in /usr/src/app/server/controllers/some_path/put.js. When running locally, it says there was an error processing the request because it couldn’t hit that URL. When running on prod, I think it is actually hitting the URL, which is returning the HTTP response and not the error. This makes sense, butI have no idea how to prevent this.

My first thought was that it was trying to fetch source maps? So I turned that setting off for this project. That didn’t seem to fix it.

Does anyone have any other ideas?

The root cause of this issue was because we have an actual API (deployed in one place) and then an API proxy that our client uses (that is deployed in another place). When our API was throwing 500s, it was basically just forwarding the 500 request in the error when logging to Sentry.

After moving our Sentry reporting directly to the API (also in Node), it was able to correctly gather the stack trace using hapi-raven-boom. Long story short, this solved the problem.