Skip to content

onError handler always captures unhandled error events (adding honoInstrumentation) #17717

Closed

Description

@cobyeastwood183

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/cloudflare - hono

SDK Version

10.12.0

Framework Version

4.9.7

Link to Sentry event

No response

Reproduction Example/SDK Setup

https://github.com/cobyeastwood183/cloudflare-hono-test

Steps to Reproduce

Expected Result

Expecting onError handler allows me to choose which errors to capture? Here are our set up docs.

Actual Result

The onError handler always captures unhandled error events in Sentry, even when Sentry.captureException is never called, instead it gets captured by errorHandler.

Additional Context

https://sentry.zendesk.com/agent/tickets/162001

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 20, 2025
  2. s1gr1d commented on Sep 22, 2025

    @s1gr1d
    Member

    Hello, we instrument the onError handler in hono automatically to capture all unhandled exceptions. So the docs are outdated here.

    Hm...but now that I think of it: It's probably better to manually call captureException in the onError handler depending on when you want to capture something - either all or just the things you didn't handle.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 22, 2025
  4. s1gr1d commented on Sep 22, 2025

    @s1gr1d
    Member

    We just had an internal discussion around that because the onError handler is instrumented on purpose (#16355).

    To make it possible to still have room for decision around capturing an error or not we'll create a honoIntegration in the Cloudflare SDK which will add the option shouldHandleError (like in the Fastify SDK). This will only capture errors with specific status codes and messages.

  5. self-assigned this
    on Sep 22, 2025
  6. changed the title [-]onError handler always captures unhandled error events[/-] [+]onError handler always captures unhandled error events (adding `honoInstrumentation`)[/+] on Sep 22, 2025
  7. cobyeastwood183 commented on Sep 22, 2025

    @cobyeastwood183
    Author

    Thank you, this would be great!

  8. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 22, 2025
  9. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 22, 2025
  10. github-actions commented on Sep 24, 2025

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #17743, which was included in the 10.15.0 release.

  11. timkelty commented on Sep 29, 2025

    @timkelty

    Thank for you adding this and updating the docs!

  12. timkelty commented on Oct 1, 2025

    @timkelty

    @s1gr1d I'm still unclear about one bit:

    By default, Sentry captures exceptions with error.status >= 500 || error.status <= 299.

    That seems to indicate that by default, only thrown HTTPExceptions will be captured by Sentry…but what happens if another error is thrown ( that doesn't have a status)?

    Looking at the code, it looks like it considers any Error eligible, and will default to capturing if the object doesn't have a status.

    This seems important to document, as the nuances around this can result in thousands of unintended captured errors maxing out an error budget, as it did for us.

  13. s1gr1d commented on Oct 9, 2025

    @s1gr1d
    Member

    Ah that's a good catch. The documentation is indeed a bit misleading here as it should say "IF there is a status, if will capture ...." - I will update this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions