Skip to content

ref(node)!: Remove deprecated fastify exports, deprecate setupFastifyErrorHandler - #23460

Open
mydea wants to merge 10 commits into
developfrom
fn/streamline-fastify
Open

ref(node)!: Remove deprecated fastify exports, deprecate setupFastifyErrorHandler#23460
mydea wants to merge 10 commits into
developfrom
fn/streamline-fastify

Conversation

@mydea

@mydea mydea commented Aug 20, 2026

Copy link
Copy Markdown
Member

This removes deprecated/unneeded fastify exports.

It also deprecates setupFastifyErrorHandler - it is no longer needed. instead, you can fully configure the error handler for all versions of fastify now via the integration.

I also removed the override tests from e2e tests, instead testing that you can still override the error handler in a node-integration-test.

Comment thread packages/server-utils/src/integrations/fastify/instrumentation.ts
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.3 kB - -
@sentry/browser - with treeshaking flags 28.47 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.81 kB - -
@sentry/browser (incl. Tracing) 48.58 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.59 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.46 kB - -
@sentry/browser (incl. Tracing, Replay) 87.98 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.36 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.7 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.39 kB - -
@sentry/browser (incl. Feedback) 47.65 kB - -
@sentry/browser (incl. sendFeedback) 35.13 kB - -
@sentry/browser (incl. FeedbackAsync) 40.28 kB - -
@sentry/browser (incl. Metrics) 31.24 kB - -
@sentry/browser (incl. Logs) 31.52 kB - -
@sentry/browser (incl. Metrics & Logs) 32.15 kB - -
@sentry/react 32.09 kB - -
@sentry/react (incl. Tracing) 50.77 kB - -
@sentry/vue 35.34 kB - -
@sentry/vue (incl. Tracing) 50.54 kB - -
@sentry/svelte 30.33 kB - -
CDN Bundle 31.61 kB - -
CDN Bundle (incl. Tracing) 48.9 kB - -
CDN Bundle (incl. Logs, Metrics) 33.8 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.82 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.31 kB - -
CDN Bundle (incl. Tracing, Replay) 86.48 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.31 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.19 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.12 kB - -
CDN Bundle - uncompressed 93.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.75 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.44 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.08 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.01 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.71 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.37 kB - -
@sentry/nextjs (client) 53.29 kB - -
@sentry/sveltekit (client) 49 kB - -
@sentry/core/server 65.38 kB - -
@sentry/core/browser 51.72 kB - -
@sentry/node 117.35 kB -0.09% -95 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB - -
@sentry/node - without tracing 82 kB +0.03% +22 B 🔺
@sentry/aws-serverless 91.37 kB +0.03% +27 B 🔺
@sentry/cloudflare (withSentry) - minified 194.35 kB - -
@sentry/cloudflare (withSentry) 480.53 kB - -

View base workflow run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d9cdd33. Configure here.

Comment thread dev-packages/node-integration-tests/suites/tracing/fastify/test.ts
@mydea
mydea marked this pull request as ready for review August 20, 2026 10:53
@mydea
mydea requested review from a team as code owners August 20, 2026 10:53
@mydea
mydea requested review from JPeer264, chargome, isaacs and s1gr1d and removed request for a team August 20, 2026 10:53
Comment thread packages/server-utils/src/integrations/fastify/errors.ts Outdated
@mydea
mydea marked this pull request as draft August 20, 2026 11:33
@mydea
mydea force-pushed the fn/streamline-fastify branch from 3004b8c to 3a04de5 Compare August 20, 2026 13:37
@mydea
mydea marked this pull request as ready for review August 20, 2026 13:55
Comment thread packages/server-utils/src/integrations/fastify/instrumentation.ts
@mydea
mydea force-pushed the fn/streamline-fastify branch from 3a04de5 to 07fbd58 Compare August 21, 2026 09:50

@isaacs isaacs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Found a few nits and questions/cleanup opportunities, mostly fairly low severity.

This is a really nice cleanup, very deep cuts. Love to see it!

The only blocking issue imo is that Fastify will silently not track errors anymore unless tracing is enabled, and requiring someone to specifically opt into the integration isn't meaningfully easier than requiring them to attach a custom error handler. I'd recommend just having it turned on all the time.

Also, there's some orphaned e2e test files that I think can be deleted:

  • dev-packages/e2e-tests/test-applications/node-fastify-3/playwright.override.config.mjs
  • dev-packages/e2e-tests/test-applications/node-fastify-4/playwright.override.config.mjs
  • dev-packages/e2e-tests/test-applications/node-fastify-5/playwright.override.config.mjs

* `captureException` deduplicates by object identity (`__sentry_captured__`), so
* only the first call sends an event. Errors that reach only one path (e.g.
* thrown in an `onRequest` hook, or on Fastify v3/v4 which has no channel) are
* captured once.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not exactly true. It'll dedupe based on the __sentry_captured__ flag, but if the object is frozen or a scalar value that won't matter.

If we're ok with duplicate events, then it's worth calling out in the docs, but I think it'd be cheap to just put a flag on the request (especially since we're already decorating it with kRequestSpan), so we could set request[kErrorCaptured] = true and use that as a guard here.

} from '@sentry/server-utils/orchestrion';
import { fastifyIntegration } from './fastify';

export function getAutoPerformanceIntegrations(): Integration[] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If fastifyIntegration() is only in the auto performance integrations, won't it mean that fastify error capture is now disabled if you turn off tracing? That seems surprising.

I'd suggest we have it on all the time (but not doing any tracing if tracing is disabled), rather than having error handling be disabled unless tracing is enabled and options.shouldHandleError is set.

};

function otelWireRoute(this: any, routeOptions: any): void {
function onRoute(this: any, routeOptions: any): void {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These renames are beautiful 👍

Comment on lines +393 to +394
fastifyInstance?.register(fastifyTracingPlugin);
fastifyInstance?.register(fastifyErrorHandlerPlugin);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought from the commit messages that a goal of this is to consolidate these two things into a single plugin, no? Can they be combined into one?

const routeName = getRequestRouteUrl(request);
const method = request.method || 'GET';

getIsolationScope().setTransactionName(`${method} ${routeName}`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The name fastifyErrorHandlerPlugin seems inconsistent, if it's also setting the transaction name and managing isolation scopes...?

function getFastifyIntegration(): FastifyIntegration | undefined {
const client = getClient();
return client?.getIntegrationByName(INTEGRATION_NAME);
return client?.getIntegrationByName(INTEGRATION_NAME) as FastifyIntegration | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this cast is only necessary because the satisfies was removed from packages/server-utils/src/integrations/fastify/index.ts line 57. It's probably better to keep the satisfies and make this client?.getIntegrationByName<FastifyIntegration>(INTEGRATION_NAME) so it's type checked.

fastifyInstance?.register(fastifyErrorHandlerPlugin);
});
},
{ id: 'Fastify.v5' },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is stale now that the same code path covers v3 and v4, right?

done();
},
{
[Symbol.for('skip-override')]: true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this also have a Symbol.for('plugin-meta') like the other one? (Recommend adding here, or deleting there, unless there's a reason for one to have it and the other not to.)

Comment on lines 12 to 13
* This is used on Fastify v5 where Sentry handles errors in the diagnostics channel.
* Fastify v3 and v4 use `setupFastifyErrorHandler` instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change

setupFastifyErrorHandler is deprecated as of this PR, so this option is simply The Way To Do It.

return false;
}

// @ts-ignore // Fastify V5 is not typed correctly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🎉

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.

2 participants