Skip to content
Merged
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
2 changes: 2 additions & 0 deletions dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@aws-sdk/client-s3": "^3.552.0",
"@google/genai": "^1.20.0",
"@hapi/hapi": "^21.3.10",
"@hono/node-server": "^1.19.4",
"@nestjs/common": "11.1.3",
"@nestjs/core": "11.1.3",
"@nestjs/platform-express": "11.1.3",
Expand All @@ -49,6 +50,7 @@
"express": "^4.21.1",
"generic-pool": "^3.9.0",
"graphql": "^16.3.0",
"hono": "^4.9.8",
"http-terminator": "^3.2.0",
"ioredis": "^5.4.1",
"kafkajs": "2.2.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
tracesSampleRate: 1.0,
transport: loggingTransport,
});
196 changes: 196 additions & 0 deletions dev-packages/node-integration-tests/suites/tracing/hono/scenario.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import { serve } from '@hono/node-server';
import * as Sentry from '@sentry/node';
import { sendPortToRunner } from '@sentry-internal/node-core-integration-tests';
import { Hono } from 'hono';
import { HTTPException } from 'hono/http-exception';

const app = new Hono();

Sentry.setupHonoErrorHandler(app);

// Global middleware to capture all requests
app.use(async function global(c, next) {
await next();
});

const basePaths = ['/sync', '/async'];
const methods = ['get', 'post', 'put', 'delete', 'patch'];

basePaths.forEach(basePath => {
// Sub-path middleware to capture all requests under the basePath
app.use(`${basePath}/*`, async function base(c, next) {
await next();
});

const baseApp = new Hono();
methods.forEach(method => {
baseApp[method]('/', c => {
const response = c.text('response 200');
if (basePath === '/sync') return response;
return Promise.resolve(response);
});

baseApp[method](
'/middleware',
// anonymous middleware
async (c, next) => {
await next();
},
c => {
const response = c.text('response 200');
if (basePath === '/sync') return response;
return Promise.resolve(response);
},
);

// anonymous middleware
baseApp[method]('/middleware/separately', async (c, next) => {
await next();
});

baseApp[method]('/middleware/separately', async c => {
const response = c.text('response 200');
if (basePath === '/sync') return response;
return Promise.resolve(response);
});

baseApp.all('/all', c => {
const response = c.text('response 200');
if (basePath === '/sync') return response;
return Promise.resolve(response);
});

baseApp.all(
'/all/middleware',
// anonymous middleware
async (c, next) => {
await next();
},
c => {
const response = c.text('response 200');
if (basePath === '/sync') return response;
return Promise.resolve(response);
},
);

// anonymous middleware
baseApp.all('/all/middleware/separately', async (c, next) => {
await next();
});

baseApp.all('/all/middleware/separately', async c => {
const response = c.text('response 200');
if (basePath === '/sync') return response;
return Promise.resolve(response);
});

baseApp.on(method, '/on', c => {
const response = c.text('response 200');
if (basePath === '/sync') return response;
return Promise.resolve(response);
});

baseApp.on(
method,
'/on/middleware',
// anonymous middleware
async (c, next) => {
await next();
},
c => {
const response = c.text('response 200');
if (basePath === '/sync') return response;
return Promise.resolve(response);
},
);

// anonymous middleware
baseApp.on(method, '/on/middleware/separately', async (c, next) => {
await next();
});

baseApp.on(method, '/on/middleware/separately', async c => {
const response = c.text('response 200');
if (basePath === '/sync') return response;
return Promise.resolve(response);
});

baseApp[method]('/401', () => {
const response = new HTTPException(401, { message: 'response 401' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp.all('/all/401', () => {
const response = new HTTPException(401, { message: 'response 401' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp.on(method, '/on/401', () => {
const response = new HTTPException(401, { message: 'response 401' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp[method]('/402', () => {
const response = new HTTPException(402, { message: 'response 402' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp.all('/all/402', () => {
const response = new HTTPException(402, { message: 'response 402' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp.on(method, '/on/402', () => {
const response = new HTTPException(402, { message: 'response 402' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp[method]('/403', () => {
const response = new HTTPException(403, { message: 'response 403' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp.all('/all/403', () => {
const response = new HTTPException(403, { message: 'response 403' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp.on(method, '/on/403', () => {
const response = new HTTPException(403, { message: 'response 403' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp[method]('/500', () => {
const response = new HTTPException(500, { message: 'response 500' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp.all('/all/500', () => {
const response = new HTTPException(500, { message: 'response 500' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});

baseApp.on(method, '/on/500', () => {
const response = new HTTPException(500, { message: 'response 500' });
if (basePath === '/sync') throw response;
return Promise.reject(response);
});
});

app.route(basePath, baseApp);
});

const port = 8787;
serve({ fetch: app.fetch, port });
sendPortToRunner(port);
Loading
Loading