Conversation
size-limit report 📦
|
Relocate the runtime-agnostic Hono instrumentation out of `@sentry/hono` into `packages/server-utils/src/integrations/hono/`, with `@sentry/hono` re-exporting it. Server-utils must not depend on `hono`, so the relocated code no longer imports it (the `Hono` class is passed in by the SDK and a vendored `honoTypes` provides the shapes). The `sentry()` middleware now builds its request handler via the shared `createHonoRequestMiddleware`. No behavior change. Also renames the `hono-4` e2e test app to `hono-4-legacy` and moves the corresponding unit tests alongside the relocated code. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Align the middleware definitions and assertions in the hono-4-legacy e2e app with the hono-4 app: anonymous function expressions (name inferred from the const binding, stable when bundled), a unique per-throw error suffix, and matching error assertions. Add a named-function middleware case, and a degraded-response test that documents the manual sentry() middleware does not capture errors thrown solely inside an internal sub-app .request() (unlike the auto-instrumentation). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
57d3514 to
09ebc47
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 09ebc47. Configure here.
s1gr1d
left a comment
There was a problem hiding this comment.
LGTM, only one comment about the deleted tests.
| test.describe('error inside internal fetch (degraded response)', () => { | ||
| // The manual `sentry()` middleware only instruments the main app's request lifecycle. An error | ||
| // thrown solely inside an internal sub-app `.request()` — whose failed response the outer handler | ||
| // swallows — is therefore NOT captured here, unlike the orchestrion auto-instrumentation in the | ||
| // `hono-4` app, which instruments every dispatched context. We assert only that the outer request | ||
| // stays healthy. | ||
| test('degrades to a 200 when the inner route fails', async ({ baseURL }) => { | ||
| const response = await fetch(`${baseURL}${STOREFRONT}/product/self-watering-plant/degraded`); | ||
| expect(response.status).toBe(200); | ||
| await expect(response.json()).resolves.toEqual({ product: null, degraded: true }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Why was this and wrapMiddlewareSpan deleted?
There was a problem hiding this comment.
we'd need to export this from server-utils to be able to test this in the hono package 😢 not 100% sure...
There was a problem hiding this comment.
ohhh 😬 then we should at least test this E2E
There was a problem hiding this comment.
I added some node-integration tests etc. to cover the things that we used to cover before. I think coverage should be decent now!
The Cloudflare and Deno Hono adapters imported applyHonoPatches, earlyPatchHono and createHonoRequestMiddleware from the main @sentry/server-utils entry, whose barrel also loads node:diagnostics_channel and other Node-only modules — which can fail at import/bundle time on Cloudflare Workers and Deno. Export the runtime-agnostic helpers from `exports.ts` (shared by both entries), sourced directly from their modules rather than the ./integrations/hono barrel, so they are available from @sentry/server-utils/no-diagnostic-channels without pulling in diagnostics-channel. Point the Cloudflare and Deno adapters at that Node-free entry. Also move the applyHonoPatches wrapper out of the barrel into the Node-free applyPatches module. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

First of two stacked PRs splitting the Hono instrumentation rework (originally #24371).
Relocates the runtime-agnostic Hono instrumentation out of
@sentry/honointo@sentry/server-utils(src/integrations/hono/), with@sentry/honore-exporting it. Since@sentry/server-utilsmust not depend onhono, the relocated code no longer imports it: theHonoclass is passed in by the SDK and a vendoredhonoTypesmodule provides the shapes. Thesentry()middleware now builds its request handler via the sharedcreateHonoRequestMiddleware. Pure relocation — no behavior change.Also renames the
hono-4e2e test app tohono-4-legacyand moves the corresponding unit tests alongside the relocated code.The orchestrion-based auto-instrumentation that builds on this lives in the stacked PR #24497.
🤖 Generated with Claude Code