-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Problem Statement
In my route handles, I throw Response
objects like:
throw Response.json(
{
error: {
code,
details,
id: sentryErrorForeignId,
message,
},
} satisfies ApiErrorResponse,
{
headers,
status,
},
);
It works as expected with Fastify, but the problem is that Sentry is catching these as if they are errors.
I get lots of these issues, like:
handleFastifyError.handleFastifyError
Level: Error
[object Response]
GET /api/gateway/v1/models
with this stack trace:
… es/.pnpm/@[email protected]/node_modules/@sentry/node/src/integrations/tracing/fastify/index.ts in handleFastifyError.handleFastifyError at line 87:5
… es/.pnpm/@[email protected]/node_modules/@sentry/node/src/integrations/tracing/fastify/index.ts in <anonymous> at line 123:24
node:diagnostics_channel in Channel.publish at line 150:9
/srv/node_modules/.pnpm/[email protected]/node_modules/fastify/lib/wrapThenable.js at line 55:22
node:internal/process/task_queues in process.processTicksAndRejections at line 105:5
I am already returning false
from shouldHandleError
:
setupFastifyErrorHandler(app, {
shouldHandleError: () => {
// We are handling errors ourselves.
// We are only using `setupFastifyErrorHandler` to setup request isolation context.
return false;
},
});
app.setErrorHandler((error, request, reply) => {
return replyWithErrorPage({ error, origin: 'setErrorHandler', reply });
});
Solution Brainstorm
Come to think about it, this is likely a bug.
Or maybe the ask is that at the moment setupFastifyErrorHandler
is overloaded with error handling logic and also logic for starting a context for every request. It would be nice to separate out those two.
Metadata
Metadata
Assignees
Labels
Projects
Status
Waiting for: Product Owner