sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Hono Support

Open smeubank opened this issue 10 months ago • 13 comments

Problem Statement

Sentry should support Hono.

Solution Brainstorm

A Hono SDK is not needed to start, but docs should available to explain setup for a Hono app.

Potential other steps:

  • Sentry platform in product
  • wrapper for node SDK where we could add future custom support for Hono framework

smeubank avatar Feb 03 '25 08:02 smeubank

Some other information about hono and Sentry:

  • Sentry Middleware for Hono, based on 3rd party toucan SDK for cloudflare: https://www.npmjs.com/package/@hono/sentry?activeTab=readme
    • related PR: https://github.com/getsentry/sentry-javascript/issues/12424
    • https://hono.dev/docs/guides/middleware#third-party-middleware
    • https://hono.dev/docs/middleware/third-party#others

smeubank avatar Feb 10 '25 14:02 smeubank

Just for context: Third-party docs for hono are already mentioned here https://docs.sentry.io/platforms/#sdks-supported-by-our-community

s1gr1d avatar Feb 10 '25 14:02 s1gr1d

and about hono + cloudflare workers? I tried

app.use('*', async (c: Context, next) => {
  console.log('Environment:', getEnvVar('ENVIRONMENT', c.env));
  console.log('Sentry DSN:', getEnvVar('SENTRY_DSN', c.env));

  sentry({dsn: getEnvVar('SENTRY_DSN', c.env), environment: getEnvVar('ENVIRONMENT', c.env)});

  const { db } = initializeDb(c.env as { DB_URL: string });
  c.set('db', db);
  c.set('env', c.env);
  await next();
});

but no errors or transactions are being captured ( locally via deno start )

marcoaleixo avatar Feb 16 '25 12:02 marcoaleixo

We're currently working on a guide for Hono https://github.com/getsentry/sentry-docs/pull/12710. With this PR we'll add setup docs that mention Cloudflare specifically. Here's a link to a preview page (warning: this might not be the final version that goes into our official docs)

Lms24 avatar Feb 17 '25 08:02 Lms24

@Lms24 does cloudflare handle the source maps or do you use tsc? Wasn't clear from docs as you don't typically use a build script with cloudflare workers.

samducker avatar Feb 20 '25 21:02 samducker

Uploading source maps is a user concern. If you don't build your worker script, there's no need for source maps :) If you build//transpile/bundle stuff, you need to upload source maps to get the stack trace mapped back to their original source code.

Lms24 avatar Feb 21 '25 07:02 Lms24

@Lms24 I think cf workers transpiles it, unless they are just running typescript without compilation? But there is no build tool in dev to output a build folder according to wrangler docs.

samducker avatar Feb 21 '25 08:02 samducker

Oh I see. This reminds me that there's this open issue about source maps on cloudflare: https://github.com/getsentry/sentry-javascript/issues/14841. Maybe your issue and this issue are related.

I believe @AbhiPrasad followed up on this with cloudflare - if CF/wrangler transpiles again, we probably need a way to use Sentry CLI afterwards. Can you think of a way how to achieve this?

Lms24 avatar Feb 21 '25 08:02 Lms24

Yeah just saying I think that should be addressed in the doc when it goes out considering it says you officially are supporting hono on workers

It should cover all of the main sentry features working with hono and workers and how to get them setup and also what if anything doesn't work.

Source maps is quite an important point in that in my view which isn't currently documented.

If it doesn't work right now for example better just to say that.

samducker avatar Feb 22 '25 08:02 samducker

Yeah just saying I think that should be addressed in the doc when it goes out considering it says you officially are supporting hono on workers

@lforst can you add a note for this on https://github.com/getsentry/sentry-docs/pull/12710 🙏

chargome avatar Feb 24 '25 08:02 chargome

Got a ticket for this today. Specifically to also add Hono support for Deno. https://sentry.zendesk.com/agent/tickets/146732

cobyeastwood183 avatar Mar 05 '25 22:03 cobyeastwood183

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

cobyeastwood183 avatar Jun 02 '25 21:06 cobyeastwood183

We would love to see this implemented in Sentry! We're launching a new project with Hono and Vue and would love to get all of our logging and instrumentation consolidated in Sentry along with error tracking.

brianlukoff avatar Jun 03 '25 13:06 brianlukoff

Hey! This issue looks interesting — mind if I take a stab at it and open a PR?

Karibash avatar Aug 05 '25 10:08 Karibash

@Karibash Thanks for your interest in opening a PR! We have planned to work on it starting around September/October. But we are happy for any contributions on this.

However, "a PR" is probably a bit difficult as this requires a variety of changes and additions. We try to keep our PRs small to make reviewing easier and add things step by step. If you want, you can start by creating a hono E2E test which is using the @sentry/node or @sentry/cloudflare SDK, just to see what's currently possible with it. From then on, we can iterate further :)

s1gr1d avatar Aug 05 '25 12:08 s1gr1d

~A PR closing this issue has just been released 🚀~

Edit: This only adds a honoIntegration for @sentry/node. We will still work on a specific Hono SDK.

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

github-actions[bot] avatar Sep 24 '25 15:09 github-actions[bot]