Skip to content

feat(node): Add shouldHandleDiagnosticsChannelError option to fastifyIntegration #16845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

onurtemizkan
Copy link
Collaborator

Resolves: #16819

This requires the Fastify integration to be manually added while initialising Sentry.

Sentry.init({
  integrations: [
    Sentry.fastifyIntegration({
      shouldHandleError(_error, _request, reply) {
        return reply.statusCode >= 500;
      },
    });
  },
});

Though I think this may be a bit confusing for Fastify v4/v3 setupFastifyErrorHandler users, as this will be a no-op in these cases, maybe we can change the name to shouldHandleDiagnosticsChannelError or something like that? 🤔

@onurtemizkan onurtemizkan requested review from mydea and andreiborza July 8, 2025 15:32
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

github-actions bot commented Jul 8, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.99 kB - -
@sentry/browser - with treeshaking flags 23.76 kB - -
@sentry/browser (incl. Tracing) 39.59 kB - -
@sentry/browser (incl. Tracing, Replay) 77.78 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 82.5 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 94.66 kB - -
@sentry/browser (incl. Feedback) 40.75 kB - -
@sentry/browser (incl. sendFeedback) 28.7 kB - -
@sentry/browser (incl. FeedbackAsync) 33.59 kB - -
@sentry/react 25.76 kB - -
@sentry/react (incl. Tracing) 41.59 kB - -
@sentry/vue 28.37 kB - -
@sentry/vue (incl. Tracing) 41.39 kB - -
@sentry/svelte 24.01 kB - -
CDN Bundle 25.5 kB - -
CDN Bundle (incl. Tracing) 39.61 kB - -
CDN Bundle (incl. Tracing, Replay) 75.59 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 81.06 kB - -
CDN Bundle - uncompressed 74.5 kB - -
CDN Bundle (incl. Tracing) - uncompressed 117.66 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 231.96 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 244.78 kB - -
@sentry/nextjs (client) 43.23 kB - -
@sentry/sveltekit (client) 40.05 kB - -
@sentry/node 162.06 kB +0.03% +33 B 🔺
@sentry/node - without tracing 98.64 kB - -
@sentry/aws-serverless 124.4 kB - -

View base workflow run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Race Condition in Error Handling

The test has a race condition. The errorEventPromise.then(() => { test.fail(); }) callback is not awaited, allowing test.fail() to execute asynchronously after the test has completed. This can lead to flaky tests where an incorrectly captured error is not reported. The promise handler should be awaited with a timeout or Promise.race() should be used.

dev-packages/e2e-tests/test-applications/node-fastify-5/tests/errors.test.ts#L36-L39

errorEventPromise.then(() => {
test.fail();
});

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@AbhiPrasad
Copy link
Member

Though I think this may be a bit confusing for Fastify v4/v3 setupFastifyErrorHandler users, as this will be a no-op in these cases, maybe we can change the name to shouldHandleDiagnosticsChannelError or something like that?

Yeah good point. I wouldn't mind changing the name to shouldHandleDiagnosticsChannelError. And then adding a doc string that explicitly says this option only works in Fastify v5

@onurtemizkan onurtemizkan changed the title feat(node): Add shouldHandleError option to fastifyIntegration feat(node): Add shouldHandleDiagnosticsChannelError option to fastifyIntegration Jul 8, 2025
@onurtemizkan onurtemizkan force-pushed the onur/fastify-dc-shouldHandleError branch from 31d50b1 to fc2159e Compare July 8, 2025 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

diagnostics channel for fastify v5 introduced a breaking change by removing custom shouldHandleError support
2 participants