Skip to content

fix(cloudflare): Capture exceptions thrown in hono #16355

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

Merged
merged 4 commits into from
May 22, 2025

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented May 21, 2025

Our cloudflare SDK captures fetch exceptions in the catch block. But hono never reaches this block where we send exceptions.
hono processes errors with their onError function (or errorHandler) and we need to capture the exception there.

This PR wraps the errorHandler of hono.

Will create an E2E test in another PR.

@s1gr1d s1gr1d changed the title Sig/hono error handler fix(cloudflare): Capture exceptions thrown in hono May 21, 2025
if (
'onError' in handler &&
'errorHandler' in handler &&
typeof handler.errorHandler === 'function' &&
Copy link
Member

Choose a reason for hiding this comment

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

So this is always defined right? We don't need to create one for a user if it's not defined?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Nice!

@s1gr1d s1gr1d merged commit 48f1a4f into develop May 22, 2025
35 checks passed
@s1gr1d s1gr1d deleted the sig/hono-errorHandler branch May 22, 2025 07:13
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.

3 participants