Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1028,8 +1028,8 @@ jobs:
node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json'
- name: Set up Bun
if:
contains(fromJSON('["node-exports-test-app","nextjs-16-bun", "elysia-bun", "elysia-bun-static", "hono-4",
"bun-bytecode", "bun-mysql"]'), matrix.test-application)
matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') ||
contains(matrix.label, 'bun')
uses: oven-sh/setup-bun@v2
with:
bun-version: '1.3.14'
Expand All @@ -1040,10 +1040,7 @@ jobs:
use-installer: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Deno
if:
matrix.test-application == 'deno' || matrix.test-application == 'deno-static' || matrix.test-application ==
'deno-redis' || matrix.test-application == 'hono-4' || matrix.test-application == 'deno-mysql' ||
matrix.test-application == 'deno-pg'
if: contains(matrix.test-application, 'deno') || contains(matrix.label, 'deno')
uses: denoland/setup-deno@v2.0.5
with:
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "hono-4",
"name": "hono-4-legacy",
"type": "module",
"version": "0.0.0",
"private": true,
Expand Down Expand Up @@ -37,15 +37,15 @@
"variants": [
{
"assert-command": "RUNTIME=node pnpm test:assert",
"label": "hono-4 (node)"
"label": "hono-4-legacy (node)"
},
{
"assert-command": "RUNTIME=bun pnpm test:assert",
"label": "hono-4 (bun)"
"label": "hono-4-legacy (bun)"
},
{
"assert-command": "RUNTIME=deno pnpm test:assert",
"label": "hono-4 (deno)"
"label": "hono-4-legacy (deno)"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { startEventProxyServer } from '@sentry-internal/test-utils';

startEventProxyServer({
port: 3031,
proxyServerName: 'hono-4',
proxyServerName: 'hono-4-legacy',
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export type Runtime = 'cloudflare' | 'node' | 'bun' | 'deno';

export const RUNTIME = (process.env.RUNTIME || 'node') as Runtime;

export const APP_NAME = 'hono-4';
export const APP_NAME = 'hono-4-legacy';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "hono-4",
"name": "hono-4-legacy",
"main": "src/entry.cloudflare.ts",
"compatibility_date": "2026-04-20",
"compatibility_flags": ["nodejs_compat"],
Expand Down
3 changes: 2 additions & 1 deletion packages/hono/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"dependencies": {
"@opentelemetry/api": "^1.9.1",
"@sentry/core": "10.67.0",
"@sentry/conventions": "^0.23.0"
"@sentry/conventions": "^0.23.0",
"@sentry/server-utils": "10.67.0"
},
"peerDependencies": {
"@cloudflare/workers-types": "^4.x",
Expand Down
14 changes: 3 additions & 11 deletions packages/hono/src/bun/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { type BaseTransportOptions, debug, type Options } from '@sentry/core';
import { init } from './sdk';
import { getConnInfo } from 'hono/bun';
import { applyHonoPatches, createHonoRequestMiddleware, type SentryHonoMiddlewareOptions } from '@sentry/server-utils';
import type { Env, Hono, MiddlewareHandler } from 'hono';
import { requestHandler, responseHandler } from '../shared/middlewareHandlers';
import { applyPatches } from '../shared/applyPatches';
import type { SentryHonoMiddlewareOptions } from '../shared/types';

export interface HonoBunOptions extends Options<BaseTransportOptions>, SentryHonoMiddlewareOptions {}

Expand All @@ -16,13 +14,7 @@ export const sentry = <E extends Env>(app: Hono<E>, options: HonoBunOptions): Mi

init(options);

applyPatches(app);
applyHonoPatches(app);

return async (context, next) => {
requestHandler(context, getConnInfo);

await next(); // Handler runs in between Request above ⤴ and Response below ⤵

responseHandler(context, options.shouldHandleError);
};
return createHonoRequestMiddleware({ getConnInfo, shouldHandleError: options.shouldHandleError });
};
23 changes: 9 additions & 14 deletions packages/hono/src/cloudflare/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { withSentry } from '@sentry/cloudflare';
import { applySdkMetadata, type BaseTransportOptions, debug, type Options } from '@sentry/core';
import { getConnInfo } from 'hono/cloudflare-workers';
import { applyHonoPatches, createHonoRequestMiddleware, type SentryHonoMiddlewareOptions } from '@sentry/server-utils';
import type { Env, Hono, MiddlewareHandler } from 'hono';
import { buildFilteredIntegrations } from '../shared/buildFilteredIntegrations';
import { LOW_QUALITY_TRANSACTION_PATTERNS } from '../shared/lowQualityTransactionPatterns';
import { requestHandler, responseHandler } from '../shared/middlewareHandlers';
import { applyPatches } from '../shared/applyPatches';
import type { SentryHonoMiddlewareOptions } from '../shared/types';

export interface HonoCloudflareOptions extends Options<BaseTransportOptions>, SentryHonoMiddlewareOptions {}

Expand Down Expand Up @@ -41,18 +39,15 @@ export function sentry<E extends Env>(
app as unknown as ExportedHandler<unknown>,
);

applyPatches(app);
applyHonoPatches(app);

return async (context, next) => {
const shouldHandleError =
return createHonoRequestMiddleware({
getConnInfo,
// Cloudflare accepts middleware options as a function of `env`, so `shouldHandleError` is only
// known per request.
resolveShouldHandleError: context =>
typeof options === 'function'
? options(context.env as E['Bindings']).shouldHandleError
: options.shouldHandleError;

requestHandler(context, getConnInfo);

await next(); // Handler runs in between Request above ⤴ and Response below ⤵

responseHandler(context, shouldHandleError);
};
: options.shouldHandleError,
});
}
8 changes: 0 additions & 8 deletions packages/hono/src/debug-build.ts

This file was deleted.

16 changes: 4 additions & 12 deletions packages/hono/src/deno/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { type BaseTransportOptions, debug, type Options } from '@sentry/core';
import { init } from './sdk';
import type { Env, Hono, MiddlewareHandler } from 'hono';
import { getConnInfo } from 'hono/deno';
import { requestHandler, responseHandler } from '../shared/middlewareHandlers';
import { applyPatches } from '../shared/applyPatches';
import type { SentryHonoMiddlewareOptions } from '../shared/types';
import { applyHonoPatches, createHonoRequestMiddleware, type SentryHonoMiddlewareOptions } from '@sentry/server-utils';
import type { Env, Hono, MiddlewareHandler } from 'hono';

export interface HonoDenoOptions extends Options<BaseTransportOptions>, SentryHonoMiddlewareOptions {}

Expand All @@ -16,13 +14,7 @@ export const sentry = <E extends Env>(app: Hono<E>, options: HonoDenoOptions): M

init(options);

applyPatches(app);

return async (context, next) => {
requestHandler(context, getConnInfo);

await next(); // Handler runs in between Request above ⤴ and Response below ⤵
applyHonoPatches(app);

responseHandler(context, options.shouldHandleError);
};
return createHonoRequestMiddleware({ getConnInfo, shouldHandleError: options.shouldHandleError });
};
5 changes: 3 additions & 2 deletions packages/hono/src/index.bun.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { earlyPatchHono } from './shared/applyPatches';
import { earlyPatchHono } from '@sentry/server-utils';
import { Hono } from 'hono';

earlyPatchHono();
earlyPatchHono(Hono);

export { sentry } from './bun/middleware';

Expand Down
5 changes: 3 additions & 2 deletions packages/hono/src/index.cloudflare.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { earlyPatchHono } from './shared/applyPatches';
import { earlyPatchHono } from '@sentry/server-utils';
import { Hono } from 'hono';

earlyPatchHono();
earlyPatchHono(Hono);

export { sentry } from './cloudflare/middleware';

Expand Down
5 changes: 3 additions & 2 deletions packages/hono/src/index.deno.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { earlyPatchHono } from './shared/applyPatches';
import { earlyPatchHono } from '@sentry/server-utils';
import { Hono } from 'hono';

earlyPatchHono();
earlyPatchHono(Hono);

export { sentry } from './deno/middleware';

Expand Down
5 changes: 3 additions & 2 deletions packages/hono/src/index.node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { earlyPatchHono } from './shared/applyPatches';
import { earlyPatchHono } from '@sentry/server-utils';
import { Hono } from 'hono';

earlyPatchHono();
earlyPatchHono(Hono);

export { sentry } from './node/middleware';

Expand Down
14 changes: 3 additions & 11 deletions packages/hono/src/node/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { type BaseTransportOptions, consoleSandbox, debug, getClient, type Options } from '@sentry/core';
import { getConnInfo } from '@hono/node-server/conninfo';
import { applyHonoPatches, createHonoRequestMiddleware, type SentryHonoMiddlewareOptions } from '@sentry/server-utils';
import type { Env, Hono, MiddlewareHandler } from 'hono';
import { requestHandler, responseHandler } from '../shared/middlewareHandlers';
import { applyPatches } from '../shared/applyPatches';
import type { SentryHonoMiddlewareOptions } from '../shared/types';

export interface HonoNodeOptions extends Options<BaseTransportOptions> {}

Expand Down Expand Up @@ -40,13 +38,7 @@ export const sentry = <E extends Env>(app: Hono<E>, options?: SentryHonoMiddlewa
}
}

applyPatches(app);
applyHonoPatches(app);

return async (context, next) => {
requestHandler(context, getConnInfo);

await next(); // Handler runs in between Request above ⤴ and Response below ⤵

responseHandler(context, options?.shouldHandleError);
};
return createHonoRequestMiddleware({ getConnInfo, shouldHandleError: options?.shouldHandleError });
};
75 changes: 0 additions & 75 deletions packages/hono/src/shared/patchAppRequest.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/hono/test/shared/applyPatches.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as SentryCore from '@sentry/core';
import { Hono } from 'hono';
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { applyPatches } from '../../src/shared/applyPatches';
import { applyHonoPatches as applyPatches } from '@sentry/server-utils';

vi.mock('@sentry/core', async () => {
const actual = await vi.importActual('@sentry/core');
Expand Down
Loading
Loading