feat(v9/node): Add shouldHandleError option to fastifyIntegration#17123
Merged
feat(v9/node): Add shouldHandleError option to fastifyIntegration#17123
Conversation
…16845) Resolves: #16819 This requires the Fastify integration to be manually added while initialising Sentry. ```typescript Sentry.init({ integrations: [ Sentry.fastifyIntegration({ shouldHandleError(_error, _request, reply) { return reply.statusCode >= 500; }, }); }, }); ``` If `shouldHandleError` is provided in `setupFastifyErrorHandler`, it overrides `shouldHandleError` provided from `fastifyIntegration`. So this should not break any existing (pre-DC) usage. In summary: - When `setupFastifyErrorHandler` is not used, `shouldHandleError` at `Sentry.init` will be used. - When `setupFastifyErrorHandler` is used but without `shouldHandleError`, `shouldHandleError` at `Sentry.init` will be used. - When in both `setupFastifyErrorHandler` and `Sentry.init` are used with `shouldHandleError`, the one in `setupFastifyErrorHandler` is used. Works for all Fastify versions supported (v3, v4, v5) Note: E2E tests for this now requires to test overrides, so they need to be run twice with both overriden and non-overriden applications. Not the prettiest solution, but I could not figure out an alternative.
onurtemizkan
approved these changes
Jul 22, 2025
Collaborator
onurtemizkan
left a comment
There was a problem hiding this comment.
Both comments from cursor are for what we're doing intentionally. We could have added a warning for the first one maybe. But as that part is for current users so I think we can assume they are using the handler correctly already.
There was a problem hiding this comment.
Bug: Incorrect Start Command Causes Test Failures
The startCommand in node-fastify-5/playwright.override.config.mjs is incorrectly set to pnpm start instead of pnpm start:override. This prevents the override tests from running app-handle-error-override.ts and properly testing the shouldHandleError functionality, unlike Fastify 3 and 4 override configurations.
dev-packages/e2e-tests/test-applications/node-fastify-5/playwright.override.config.mjs#L3-L4
Was this report helpful? Give feedback by reacting with 👍 or 👎
Contributor
size-limit report 📦
|
This was referenced Sep 29, 2025
This was referenced Oct 7, 2025
This was referenced Oct 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #16845
closes #17123