Skip to content

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

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

ref(node)!: Remove deprecated fastify exports, deprecate setupFastifyErrorHandler#23460
mydea wants to merge 9 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.28 kB -0.09% -96 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 81.91 kB +0.03% +24 B 🔺
@sentry/aws-serverless 91.32 kB +0.03% +24 B 🔺
@sentry/cloudflare (withSentry) - minified 213.98 kB - -
@sentry/cloudflare (withSentry) 528.93 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 on lines +409 to +411
fastify.addHook('onError', async (request, reply, error) => {
handleFastifyError(error, request, reply);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: Primitive errors thrown in Fastify v5 route handlers are captured twice because the deduplication logic in checkOrSetAlreadyCaught fails for non-object types.
Severity: LOW

Suggested Fix

Wrap primitive errors in a new Error object within the handleFastifyError function before they are passed to checkOrSetAlreadyCaught and captureException. This will allow the __sentry_captured__ property to be set correctly, ensuring the error is only captured once.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/server-utils/src/integrations/fastify/instrumentation.ts#L409-L411

Potential issue: In Fastify v5, when a primitive value like a string or number is thrown
in a route handler, it gets captured and sent to Sentry twice. This occurs because two
separate error handling paths, the `tracing:fastify.request.handler:error` diagnostics
channel and the `onError` hook, both attempt to report the error. The deduplication
mechanism, `checkOrSetAlreadyCaught`, is designed to prevent this by setting a
`__sentry_captured__` property on the error. However, this function cannot set
properties on primitive values, causing the deduplication to fail silently and both
paths to report the same error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

seems acceptable

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.

1 participant