From b2cb4f761296548c7322b0975154b9625e2eae72 Mon Sep 17 00:00:00 2001 From: s1gr1d <32902192+s1gr1d@users.noreply.github.com> Date: Mon, 20 Apr 2026 14:36:58 +0200 Subject: [PATCH 1/4] add minimal hono starter --- .../test-applications/hono-4-cf/.gitignore | 33 ++++++++++++++++ .../test-applications/hono-4-cf/package.json | 15 ++++++++ .../test-applications/hono-4-cf/src/index.ts | 9 +++++ .../test-applications/hono-4-cf/tsconfig.json | 12 ++++++ .../hono-4-cf/wrangler.jsonc | 38 +++++++++++++++++++ 5 files changed, 107 insertions(+) create mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore create mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/package.json create mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts create mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json create mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore b/dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore new file mode 100644 index 000000000000..e319e0635f90 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore @@ -0,0 +1,33 @@ +# prod +dist/ + +# dev +.yarn/ +!.yarn/releases +.vscode/* +!.vscode/launch.json +!.vscode/*.code-snippets +.idea/workspace.xml +.idea/usage.statistics.xml +.idea/shelf + +# deps +node_modules/ +.wrangler + +# env +.env +.env.production +.dev.vars + +# logs +logs/ +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +# misc +.DS_Store diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/package.json b/dev-packages/e2e-tests/test-applications/hono-4-cf/package.json new file mode 100644 index 000000000000..e6faf399daf7 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/package.json @@ -0,0 +1,15 @@ +{ + "name": "hono-4-cf", + "type": "module", + "scripts": { + "dev": "wrangler dev", + "deploy": "wrangler deploy --minify", + "cf-typegen": "wrangler types --env-interface CloudflareBindings" + }, + "dependencies": { + "hono": "^4.12.14" + }, + "devDependencies": { + "wrangler": "^4.4.0" + } +} diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts b/dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts new file mode 100644 index 000000000000..152196c64ccc --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts @@ -0,0 +1,9 @@ +import { Hono } from 'hono'; + +const app = new Hono(); + +app.get('/', c => { + return c.text('Hello Hono!'); +}); + +export default app; diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json b/dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json new file mode 100644 index 000000000000..5e1f025cc70d --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "Bundler", + "strict": true, + "skipLibCheck": true, + "lib": ["ESNext"], + "jsx": "react-jsx", + "jsxImportSource": "hono/jsx" + } +} diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc b/dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc new file mode 100644 index 000000000000..92cc7c6a4ebb --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc @@ -0,0 +1,38 @@ +{ + "$schema": "node_modules/wrangler/config-schema.json", + "name": "hono-4-cf", + "main": "src/index.ts", + "compatibility_date": "2026-04-20", + // "compatibility_flags": [ + // "nodejs_compat" + // ], + // "vars": { + // "MY_VAR": "my-variable" + // }, + // "kv_namespaces": [ + // { + // "binding": "MY_KV_NAMESPACE", + // "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + // } + // ], + // "r2_buckets": [ + // { + // "binding": "MY_BUCKET", + // "bucket_name": "my-bucket" + // } + // ], + // "d1_databases": [ + // { + // "binding": "MY_DB", + // "database_name": "my-database", + // "database_id": "" + // } + // ], + // "ai": { + // "binding": "AI" + // }, + // "observability": { + // "enabled": true, + // "head_sampling_rate": 1 + // } +} From d516d6f428efb3c135c0e5631f7ee7af2a58e686 Mon Sep 17 00:00:00 2001 From: s1gr1d <32902192+s1gr1d@users.noreply.github.com> Date: Mon, 20 Apr 2026 16:56:07 +0200 Subject: [PATCH 2/4] test(hono): Add E2E test for Hono on Cloudflare --- .../test-applications/hono-4-cf/.gitignore | 3 ++ .../test-applications/hono-4-cf/.npmrc | 2 + .../test-applications/hono-4-cf/package.json | 19 +++++-- .../hono-4-cf/playwright.config.ts | 22 ++++++++ .../test-applications/hono-4-cf/src/index.ts | 28 +++++++++- .../hono-4-cf/start-event-proxy.mjs | 6 +++ .../hono-4-cf/tests/errors.test.ts | 52 +++++++++++++++++++ .../hono-4-cf/tests/tracing.test.ts | 39 ++++++++++++++ .../test-applications/hono-4-cf/tsconfig.json | 3 +- .../hono-4-cf/wrangler.jsonc | 33 +----------- 10 files changed, 170 insertions(+), 37 deletions(-) create mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/.npmrc create mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/playwright.config.ts create mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/start-event-proxy.mjs create mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/tests/errors.test.ts create mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/tests/tracing.test.ts diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore b/dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore index e319e0635f90..534f51704346 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore @@ -29,5 +29,8 @@ yarn-error.log* pnpm-debug.log* lerna-debug.log* +# test +test-results + # misc .DS_Store diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/.npmrc b/dev-packages/e2e-tests/test-applications/hono-4-cf/.npmrc new file mode 100644 index 000000000000..070f80f05092 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/.npmrc @@ -0,0 +1,2 @@ +@sentry:registry=http://127.0.0.1:4873 +@sentry-internal:registry=http://127.0.0.1:4873 diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/package.json b/dev-packages/e2e-tests/test-applications/hono-4-cf/package.json index e6faf399daf7..415b93d32424 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/package.json +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/package.json @@ -1,15 +1,28 @@ { "name": "hono-4-cf", "type": "module", + "version": "0.0.0", + "private": true, "scripts": { - "dev": "wrangler dev", + "dev": "wrangler dev --var \"E2E_TEST_DSN:$E2E_TEST_DSN\" --log-level=$(test $CI && echo 'none' || echo 'log')", + "build": "wrangler deploy --dry-run", "deploy": "wrangler deploy --minify", - "cf-typegen": "wrangler types --env-interface CloudflareBindings" + "cf-typegen": "wrangler types --env-interface CloudflareBindings", + "test:build": "pnpm install && pnpm build", + "test:assert": "TEST_ENV=production playwright test" }, "dependencies": { + "@sentry/hono": "latest || *", "hono": "^4.12.14" }, "devDependencies": { - "wrangler": "^4.4.0" + "@playwright/test": "~1.56.0", + "@cloudflare/workers-types": "^4.20240725.0", + "@sentry-internal/test-utils": "link:../../../test-utils", + "typescript": "^5.5.2", + "wrangler": "^4.61.0" + }, + "volta": { + "extends": "../../package.json" } } diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/playwright.config.ts b/dev-packages/e2e-tests/test-applications/hono-4-cf/playwright.config.ts new file mode 100644 index 000000000000..1cca1e0ee184 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/playwright.config.ts @@ -0,0 +1,22 @@ +import { getPlaywrightConfig } from '@sentry-internal/test-utils'; + +const testEnv = process.env.TEST_ENV; + +if (!testEnv) { + throw new Error('No test env defined'); +} + +const APP_PORT = 38787; + +const config = getPlaywrightConfig( + { + startCommand: `pnpm dev --port ${APP_PORT}`, + port: APP_PORT, + }, + { + workers: '100%', + retries: 0, + }, +); + +export default config; diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts b/dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts index 152196c64ccc..b8ebd909821a 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts @@ -1,9 +1,35 @@ import { Hono } from 'hono'; +import { HTTPException } from 'hono/http-exception'; +import { sentry } from '@sentry/hono/cloudflare'; -const app = new Hono(); +const app = new Hono<{ Bindings: { E2E_TEST_DSN: string } }>(); + +app.use( + sentry(app, env => ({ + dsn: env.E2E_TEST_DSN, + environment: 'qa', + tracesSampleRate: 1.0, + tunnel: 'http://localhost:3031/', // proxy server + })), +); app.get('/', c => { return c.text('Hello Hono!'); }); +app.get('/test-param/:paramId', c => { + return c.json({ paramId: c.req.param('paramId') }); +}); + +app.get('/error/:cause', c => { + throw new Error('This is a test error for Sentry!', { + cause: c.req.param('cause'), + }); +}); + +app.get('/http-exception/:code', c => { + const code = Number(c.req.param('code')) as Parameters[0]; + throw new HTTPException(code, { message: `HTTPException ${code}` }); +}); + export default app; diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/start-event-proxy.mjs b/dev-packages/e2e-tests/test-applications/hono-4-cf/start-event-proxy.mjs new file mode 100644 index 000000000000..bccc9f3be95a --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/start-event-proxy.mjs @@ -0,0 +1,6 @@ +import { startEventProxyServer } from '@sentry-internal/test-utils'; + +startEventProxyServer({ + port: 3031, + proxyServerName: 'hono-4-cf', +}); diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/errors.test.ts new file mode 100644 index 000000000000..56d7fb599045 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/errors.test.ts @@ -0,0 +1,52 @@ +import { expect, test } from '@playwright/test'; +import { waitForError } from '@sentry-internal/test-utils'; + +test('captures error thrown in route handler', async ({ baseURL }) => { + const errorWaiter = waitForError('hono-4-cf', event => { + return event.exception?.values?.[0]?.value === 'This is a test error for Sentry!'; + }); + + const response = await fetch(`${baseURL}/error/test-cause`); + expect(response.status).toBe(500); + + const event = await errorWaiter; + expect(event.exception?.values?.[0]?.value).toBe('This is a test error for Sentry!'); +}); + +test('captures HTTPException with 502 status', async ({ baseURL }) => { + const errorWaiter = waitForError('hono-4-cf', event => { + return event.exception?.values?.[0]?.value === 'HTTPException 502'; + }); + + const response = await fetch(`${baseURL}/http-exception/502`); + expect(response.status).toBe(502); + + const event = await errorWaiter; + expect(event.exception?.values?.[0]?.value).toBe('HTTPException 502'); +}); + +// TODO: 401 and 404 HTTPExceptions should not be captured by Sentry by default, +// but currently they are. Fix the filtering and update these tests accordingly. +test('captures HTTPException with 401 status', async ({ baseURL }) => { + const errorWaiter = waitForError('hono-4-cf', event => { + return event.exception?.values?.[0]?.value === 'HTTPException 401'; + }); + + const response = await fetch(`${baseURL}/http-exception/401`); + expect(response.status).toBe(401); + + const event = await errorWaiter; + expect(event.exception?.values?.[0]?.value).toBe('HTTPException 401'); +}); + +test('captures HTTPException with 404 status', async ({ baseURL }) => { + const errorWaiter = waitForError('hono-4-cf', event => { + return event.exception?.values?.[0]?.value === 'HTTPException 404'; + }); + + const response = await fetch(`${baseURL}/http-exception/404`); + expect(response.status).toBe(404); + + const event = await errorWaiter; + expect(event.exception?.values?.[0]?.value).toBe('HTTPException 404'); +}); diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/tracing.test.ts b/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/tracing.test.ts new file mode 100644 index 000000000000..b2ac26c89d44 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/tracing.test.ts @@ -0,0 +1,39 @@ +import { expect, test } from '@playwright/test'; +import { waitForTransaction } from '@sentry-internal/test-utils'; + +test('sends a transaction for the index route', async ({ baseURL }) => { + const transactionWaiter = waitForTransaction('hono-4-cf', event => { + return event.transaction === 'GET /'; + }); + + const response = await fetch(`${baseURL}/`); + expect(response.status).toBe(200); + + const transaction = await transactionWaiter; + expect(transaction.contexts?.trace?.op).toBe('http.server'); +}); + +test('sends a transaction for a parameterized route', async ({ baseURL }) => { + const transactionWaiter = waitForTransaction('hono-4-cf', event => { + return event.transaction === 'GET /test-param/:paramId'; + }); + + const response = await fetch(`${baseURL}/test-param/123`); + expect(response.status).toBe(200); + + const transaction = await transactionWaiter; + expect(transaction.contexts?.trace?.op).toBe('http.server'); + expect(transaction.transaction).toBe('GET /test-param/:paramId'); +}); + +test('sends a transaction for a route that throws', async ({ baseURL }) => { + const transactionWaiter = waitForTransaction('hono-4-cf', event => { + return event.transaction === 'GET /error/:cause'; + }); + + await fetch(`${baseURL}/error/test-cause`); + + const transaction = await transactionWaiter; + expect(transaction.contexts?.trace?.op).toBe('http.server'); + expect(transaction.contexts?.trace?.status).toBe('internal_error'); +}); diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json b/dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json index 5e1f025cc70d..3c4abeff44d6 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json @@ -7,6 +7,7 @@ "skipLibCheck": true, "lib": ["ESNext"], "jsx": "react-jsx", - "jsxImportSource": "hono/jsx" + "jsxImportSource": "hono/jsx", + "types": ["@cloudflare/workers-types"] } } diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc b/dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc index 92cc7c6a4ebb..2ac330d50b1d 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc +++ b/dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc @@ -3,36 +3,5 @@ "name": "hono-4-cf", "main": "src/index.ts", "compatibility_date": "2026-04-20", - // "compatibility_flags": [ - // "nodejs_compat" - // ], - // "vars": { - // "MY_VAR": "my-variable" - // }, - // "kv_namespaces": [ - // { - // "binding": "MY_KV_NAMESPACE", - // "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - // } - // ], - // "r2_buckets": [ - // { - // "binding": "MY_BUCKET", - // "bucket_name": "my-bucket" - // } - // ], - // "d1_databases": [ - // { - // "binding": "MY_DB", - // "database_name": "my-database", - // "database_id": "" - // } - // ], - // "ai": { - // "binding": "AI" - // }, - // "observability": { - // "enabled": true, - // "head_sampling_rate": 1 - // } + "compatibility_flags": ["nodejs_compat"], } From 5d92988cea3c8120429563c7bc55f9e51776b6dd Mon Sep 17 00:00:00 2001 From: s1gr1d <32902192+s1gr1d@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:30:39 +0200 Subject: [PATCH 3/4] add test variants (cf, node, bun) --- .../test-applications/hono-4-cf/.gitignore | 36 ------------- .../test-applications/hono-4-cf/.npmrc | 2 - .../test-applications/hono-4-cf/package.json | 28 ---------- .../hono-4-cf/playwright.config.ts | 22 -------- .../test-applications/hono-4-cf/src/index.ts | 35 ------------- .../hono-4-cf/start-event-proxy.mjs | 6 --- .../hono-4-cf/tests/errors.test.ts | 52 ------------------- .../hono-4-cf/tests/tracing.test.ts | 39 -------------- .../test-applications/hono-4-cf/tsconfig.json | 13 ----- .../hono-4-cf/wrangler.jsonc | 7 --- 10 files changed, 240 deletions(-) delete mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore delete mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/.npmrc delete mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/package.json delete mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/playwright.config.ts delete mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts delete mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/start-event-proxy.mjs delete mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/tests/errors.test.ts delete mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/tests/tracing.test.ts delete mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json delete mode 100644 dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore b/dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore deleted file mode 100644 index 534f51704346..000000000000 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -# prod -dist/ - -# dev -.yarn/ -!.yarn/releases -.vscode/* -!.vscode/launch.json -!.vscode/*.code-snippets -.idea/workspace.xml -.idea/usage.statistics.xml -.idea/shelf - -# deps -node_modules/ -.wrangler - -# env -.env -.env.production -.dev.vars - -# logs -logs/ -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -# test -test-results - -# misc -.DS_Store diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/.npmrc b/dev-packages/e2e-tests/test-applications/hono-4-cf/.npmrc deleted file mode 100644 index 070f80f05092..000000000000 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/.npmrc +++ /dev/null @@ -1,2 +0,0 @@ -@sentry:registry=http://127.0.0.1:4873 -@sentry-internal:registry=http://127.0.0.1:4873 diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/package.json b/dev-packages/e2e-tests/test-applications/hono-4-cf/package.json deleted file mode 100644 index 415b93d32424..000000000000 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "hono-4-cf", - "type": "module", - "version": "0.0.0", - "private": true, - "scripts": { - "dev": "wrangler dev --var \"E2E_TEST_DSN:$E2E_TEST_DSN\" --log-level=$(test $CI && echo 'none' || echo 'log')", - "build": "wrangler deploy --dry-run", - "deploy": "wrangler deploy --minify", - "cf-typegen": "wrangler types --env-interface CloudflareBindings", - "test:build": "pnpm install && pnpm build", - "test:assert": "TEST_ENV=production playwright test" - }, - "dependencies": { - "@sentry/hono": "latest || *", - "hono": "^4.12.14" - }, - "devDependencies": { - "@playwright/test": "~1.56.0", - "@cloudflare/workers-types": "^4.20240725.0", - "@sentry-internal/test-utils": "link:../../../test-utils", - "typescript": "^5.5.2", - "wrangler": "^4.61.0" - }, - "volta": { - "extends": "../../package.json" - } -} diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/playwright.config.ts b/dev-packages/e2e-tests/test-applications/hono-4-cf/playwright.config.ts deleted file mode 100644 index 1cca1e0ee184..000000000000 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/playwright.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { getPlaywrightConfig } from '@sentry-internal/test-utils'; - -const testEnv = process.env.TEST_ENV; - -if (!testEnv) { - throw new Error('No test env defined'); -} - -const APP_PORT = 38787; - -const config = getPlaywrightConfig( - { - startCommand: `pnpm dev --port ${APP_PORT}`, - port: APP_PORT, - }, - { - workers: '100%', - retries: 0, - }, -); - -export default config; diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts b/dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts deleted file mode 100644 index b8ebd909821a..000000000000 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/src/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Hono } from 'hono'; -import { HTTPException } from 'hono/http-exception'; -import { sentry } from '@sentry/hono/cloudflare'; - -const app = new Hono<{ Bindings: { E2E_TEST_DSN: string } }>(); - -app.use( - sentry(app, env => ({ - dsn: env.E2E_TEST_DSN, - environment: 'qa', - tracesSampleRate: 1.0, - tunnel: 'http://localhost:3031/', // proxy server - })), -); - -app.get('/', c => { - return c.text('Hello Hono!'); -}); - -app.get('/test-param/:paramId', c => { - return c.json({ paramId: c.req.param('paramId') }); -}); - -app.get('/error/:cause', c => { - throw new Error('This is a test error for Sentry!', { - cause: c.req.param('cause'), - }); -}); - -app.get('/http-exception/:code', c => { - const code = Number(c.req.param('code')) as Parameters[0]; - throw new HTTPException(code, { message: `HTTPException ${code}` }); -}); - -export default app; diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/start-event-proxy.mjs b/dev-packages/e2e-tests/test-applications/hono-4-cf/start-event-proxy.mjs deleted file mode 100644 index bccc9f3be95a..000000000000 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/start-event-proxy.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { startEventProxyServer } from '@sentry-internal/test-utils'; - -startEventProxyServer({ - port: 3031, - proxyServerName: 'hono-4-cf', -}); diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/errors.test.ts deleted file mode 100644 index 56d7fb599045..000000000000 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/errors.test.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { expect, test } from '@playwright/test'; -import { waitForError } from '@sentry-internal/test-utils'; - -test('captures error thrown in route handler', async ({ baseURL }) => { - const errorWaiter = waitForError('hono-4-cf', event => { - return event.exception?.values?.[0]?.value === 'This is a test error for Sentry!'; - }); - - const response = await fetch(`${baseURL}/error/test-cause`); - expect(response.status).toBe(500); - - const event = await errorWaiter; - expect(event.exception?.values?.[0]?.value).toBe('This is a test error for Sentry!'); -}); - -test('captures HTTPException with 502 status', async ({ baseURL }) => { - const errorWaiter = waitForError('hono-4-cf', event => { - return event.exception?.values?.[0]?.value === 'HTTPException 502'; - }); - - const response = await fetch(`${baseURL}/http-exception/502`); - expect(response.status).toBe(502); - - const event = await errorWaiter; - expect(event.exception?.values?.[0]?.value).toBe('HTTPException 502'); -}); - -// TODO: 401 and 404 HTTPExceptions should not be captured by Sentry by default, -// but currently they are. Fix the filtering and update these tests accordingly. -test('captures HTTPException with 401 status', async ({ baseURL }) => { - const errorWaiter = waitForError('hono-4-cf', event => { - return event.exception?.values?.[0]?.value === 'HTTPException 401'; - }); - - const response = await fetch(`${baseURL}/http-exception/401`); - expect(response.status).toBe(401); - - const event = await errorWaiter; - expect(event.exception?.values?.[0]?.value).toBe('HTTPException 401'); -}); - -test('captures HTTPException with 404 status', async ({ baseURL }) => { - const errorWaiter = waitForError('hono-4-cf', event => { - return event.exception?.values?.[0]?.value === 'HTTPException 404'; - }); - - const response = await fetch(`${baseURL}/http-exception/404`); - expect(response.status).toBe(404); - - const event = await errorWaiter; - expect(event.exception?.values?.[0]?.value).toBe('HTTPException 404'); -}); diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/tracing.test.ts b/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/tracing.test.ts deleted file mode 100644 index b2ac26c89d44..000000000000 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/tests/tracing.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { expect, test } from '@playwright/test'; -import { waitForTransaction } from '@sentry-internal/test-utils'; - -test('sends a transaction for the index route', async ({ baseURL }) => { - const transactionWaiter = waitForTransaction('hono-4-cf', event => { - return event.transaction === 'GET /'; - }); - - const response = await fetch(`${baseURL}/`); - expect(response.status).toBe(200); - - const transaction = await transactionWaiter; - expect(transaction.contexts?.trace?.op).toBe('http.server'); -}); - -test('sends a transaction for a parameterized route', async ({ baseURL }) => { - const transactionWaiter = waitForTransaction('hono-4-cf', event => { - return event.transaction === 'GET /test-param/:paramId'; - }); - - const response = await fetch(`${baseURL}/test-param/123`); - expect(response.status).toBe(200); - - const transaction = await transactionWaiter; - expect(transaction.contexts?.trace?.op).toBe('http.server'); - expect(transaction.transaction).toBe('GET /test-param/:paramId'); -}); - -test('sends a transaction for a route that throws', async ({ baseURL }) => { - const transactionWaiter = waitForTransaction('hono-4-cf', event => { - return event.transaction === 'GET /error/:cause'; - }); - - await fetch(`${baseURL}/error/test-cause`); - - const transaction = await transactionWaiter; - expect(transaction.contexts?.trace?.op).toBe('http.server'); - expect(transaction.contexts?.trace?.status).toBe('internal_error'); -}); diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json b/dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json deleted file mode 100644 index 3c4abeff44d6..000000000000 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "lib": ["ESNext"], - "jsx": "react-jsx", - "jsxImportSource": "hono/jsx", - "types": ["@cloudflare/workers-types"] - } -} diff --git a/dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc b/dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc deleted file mode 100644 index 2ac330d50b1d..000000000000 --- a/dev-packages/e2e-tests/test-applications/hono-4-cf/wrangler.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "$schema": "node_modules/wrangler/config-schema.json", - "name": "hono-4-cf", - "main": "src/index.ts", - "compatibility_date": "2026-04-20", - "compatibility_flags": ["nodejs_compat"], -} From bcf018519d9c8b0d4edb130ea62d2b0897b1b8dd Mon Sep 17 00:00:00 2001 From: s1gr1d <32902192+s1gr1d@users.noreply.github.com> Date: Tue, 21 Apr 2026 15:08:23 +0200 Subject: [PATCH 4/4] fix(hono): Remove `undefined` from options type --- .../e2e-tests/test-applications/hono-4/src/entry.bun.ts | 3 +-- dev-packages/e2e-tests/test-applications/hono-4/src/routes.ts | 2 +- packages/hono/src/bun/middleware.ts | 2 +- packages/hono/src/node/middleware.ts | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/hono-4/src/entry.bun.ts b/dev-packages/e2e-tests/test-applications/hono-4/src/entry.bun.ts index 2a27d1adb8a9..e057eb78d4c5 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4/src/entry.bun.ts +++ b/dev-packages/e2e-tests/test-applications/hono-4/src/entry.bun.ts @@ -2,10 +2,9 @@ import { Hono } from 'hono'; import { sentry } from '@sentry/hono/bun'; import { addRoutes } from './routes'; -const app = new Hono<{ Bindings: { E2E_TEST_DSN: string } }>(); +const app = new Hono(); app.use( - // @ts-expect-error - Env is not yet in type sentry(app, { dsn: process.env.E2E_TEST_DSN, environment: 'qa', diff --git a/dev-packages/e2e-tests/test-applications/hono-4/src/routes.ts b/dev-packages/e2e-tests/test-applications/hono-4/src/routes.ts index fbb273c7c425..a3272bc45ca3 100644 --- a/dev-packages/e2e-tests/test-applications/hono-4/src/routes.ts +++ b/dev-packages/e2e-tests/test-applications/hono-4/src/routes.ts @@ -1,7 +1,7 @@ import type { Hono } from 'hono'; import { HTTPException } from 'hono/http-exception'; -export function addRoutes(app: Hono<{ Bindings: { E2E_TEST_DSN: string } }>): void { +export function addRoutes(app: Hono<{ Bindings?: { E2E_TEST_DSN: string } }>): void { app.get('/', c => { return c.text('Hello Hono!'); }); diff --git a/packages/hono/src/bun/middleware.ts b/packages/hono/src/bun/middleware.ts index cbca87ea6b9e..fbcbffb15019 100644 --- a/packages/hono/src/bun/middleware.ts +++ b/packages/hono/src/bun/middleware.ts @@ -9,7 +9,7 @@ export interface HonoBunOptions extends Options {} /** * Sentry middleware for Hono running in a Bun runtime environment. */ -export const sentry = (app: Hono, options: HonoBunOptions | undefined = {}): MiddlewareHandler => { +export const sentry = (app: Hono, options: HonoBunOptions): MiddlewareHandler => { const isDebug = options.debug; isDebug && debug.log('Initialized Sentry Hono middleware (Bun)'); diff --git a/packages/hono/src/node/middleware.ts b/packages/hono/src/node/middleware.ts index 1dbca92d02e5..2a85575db0d8 100644 --- a/packages/hono/src/node/middleware.ts +++ b/packages/hono/src/node/middleware.ts @@ -9,7 +9,7 @@ export interface HonoNodeOptions extends Options {} /** * Sentry middleware for Hono running in a Node runtime environment. */ -export const sentry = (app: Hono, options: HonoNodeOptions | undefined = {}): MiddlewareHandler => { +export const sentry = (app: Hono, options: HonoNodeOptions): MiddlewareHandler => { const isDebug = options.debug; isDebug && debug.log('Initialized Sentry Hono middleware (Node)');