Skip to content

Commit cd5d720

Browse files
authored
Merge branch 'develop' into sig/use-shared-const
2 parents c4d9f5c + 0db41f9 commit cd5d720

280 files changed

Lines changed: 1761 additions & 540 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.size-limit.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,23 @@ module.exports = [
357357
limit: '51 KB',
358358
disablePlugins: ['@size-limit/esbuild'],
359359
},
360+
// Core SDK subpath entry points (ESM)
361+
{
362+
name: '@sentry/core/server',
363+
path: 'packages/core/build/esm/server.js',
364+
import: '*',
365+
gzip: true,
366+
limit: '78 KB',
367+
disablePlugins: ['@size-limit/esbuild'],
368+
},
369+
{
370+
name: '@sentry/core/browser',
371+
path: 'packages/core/build/esm/browser.js',
372+
import: '*',
373+
gzip: true,
374+
limit: '64 KB',
375+
disablePlugins: ['@size-limit/esbuild'],
376+
},
360377
// Node-Core SDK (ESM)
361378
{
362379
name: '@sentry/node-core',

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7-
Work in this release was contributed by @abcang and @ahmadio. Thank you for your contributions!
7+
Work in this release was contributed by @abcang, @ahmadio, and @victorgarciaesgi. Thank you for your contributions!
88

99
- **feat(core): Support array attributes for spans, logs, and metrics ([#20427](https://github.com/getsentry/sentry-javascript/pull/20427))**
1010

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { Hono } from 'hono';
2+
import { HTTPException } from 'hono/http-exception';
3+
4+
const ITEMS: Record<string, { name: string; stock: number; price: number }> = {
5+
'self-watering-plant': { name: 'Self-Watering Plant', stock: 5, price: 2500 },
6+
'solar-powered-cyberdeck': { name: 'Solar-Powered Cyberdeck', stock: 0, price: 5000 },
7+
};
8+
9+
// Inventory service — standalone sub-app used as a data source.
10+
// Mounted on the main app AND called internally via .request() from the storefront.
11+
const inventoryApp = new Hono();
12+
13+
inventoryApp.get('/item/:productId', c => {
14+
const productId = c.req.param('productId');
15+
const item = ITEMS[productId];
16+
if (!item) {
17+
throw new HTTPException(404, { message: `Item ${productId} not found` });
18+
}
19+
return c.json({ productId, ...item });
20+
});
21+
22+
inventoryApp.get('/item/:productId/stock', c => {
23+
const productId = c.req.param('productId');
24+
const item = ITEMS[productId];
25+
if (!item) {
26+
throw new HTTPException(404, { message: `Stock check failed: ${productId}` });
27+
}
28+
return c.json({ productId, inStock: item.stock > 0, quantity: item.stock });
29+
});
30+
31+
// Storefront service — orchestrates internal .request() calls to inventoryApp.
32+
const storefrontApp = new Hono();
33+
34+
storefrontApp.use('/*', async function storefrontAuth(_c, next) {
35+
await new Promise(resolve => setTimeout(resolve, 10));
36+
await next();
37+
});
38+
39+
// Single internal fetch: look up one product
40+
storefrontApp.get('/product/:productId', async c => {
41+
const res = await inventoryApp.request(`/item/${c.req.param('productId')}`);
42+
if (!res.ok) {
43+
throw new HTTPException(404, { message: 'Product not found' });
44+
}
45+
const item = await res.json();
46+
return c.json({ product: item, source: 'storefront' });
47+
});
48+
49+
// Parallel internal fetches: compare two products via Promise.all
50+
storefrontApp.get('/compare/:productId1/:productId2', async c => {
51+
const [res1, res2] = await Promise.all([
52+
inventoryApp.request(`/item/${c.req.param('productId1')}`),
53+
inventoryApp.request(`/item/${c.req.param('productId2')}`),
54+
]);
55+
if (!res1.ok || !res2.ok) {
56+
throw new HTTPException(404, { message: 'One or more products not found' });
57+
}
58+
const [item1, item2] = (await Promise.all([res1.json(), res2.json()])) as [
59+
Record<string, number>,
60+
Record<string, number>,
61+
];
62+
return c.json({
63+
items: [item1, item2],
64+
priceDifference: Math.abs(item1.price - item2.price),
65+
});
66+
});
67+
68+
// Sequential chained fetches: look up item, then check its stock
69+
storefrontApp.get('/product/:productId/availability', async c => {
70+
const itemRes = await inventoryApp.request(`/item/${c.req.param('productId')}`);
71+
if (!itemRes.ok) {
72+
throw new HTTPException(404, { message: 'Product not found' });
73+
}
74+
const item: Record<string, string | number> = await itemRes.json();
75+
76+
const stockRes = await inventoryApp.request(`/item/${item.productId}/stock`);
77+
const stock: Record<string, string | number | boolean> = await stockRes.json();
78+
79+
return c.json({
80+
product: item.name,
81+
available: stock.inStock,
82+
quantity: stock.quantity,
83+
});
84+
});
85+
86+
// Error propagation: internal 404 causes the handler to throw a plain Error
87+
storefrontApp.get('/product-or-throw/:productId', async c => {
88+
const res = await inventoryApp.request(`/item/${c.req.param('productId')}`);
89+
if (!res.ok) {
90+
throw new Error(`Failed to fetch product: ${c.req.param('productId')}`);
91+
}
92+
return c.json({ product: await res.json() });
93+
});
94+
95+
const multiFetchRoutes = new Hono();
96+
multiFetchRoutes.route('/inventory', inventoryApp);
97+
multiFetchRoutes.route('/storefront', storefrontApp);
98+
99+
export { multiFetchRoutes };

dev-packages/e2e-tests/test-applications/hono-4/src/routes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { HTTPException } from 'hono/http-exception';
33
import { failingMiddleware, middlewareA, middlewareB } from './middleware';
44
import { errorRoutes } from './route-groups/test-errors';
55
import { middlewareRoutes, subAppWithInlineMiddleware, subAppWithMiddleware } from './route-groups/test-middleware';
6+
import { multiFetchRoutes } from './route-groups/test-multi-fetch';
67
import { routePatterns } from './route-groups/test-route-patterns';
78

89
export function addRoutes(app: Hono<{ Bindings?: { E2E_TEST_DSN: string } }>): void {
@@ -48,4 +49,7 @@ export function addRoutes(app: Hono<{ Bindings?: { E2E_TEST_DSN: string } }>): v
4849

4950
// Error-specific routes: onError handler, nested sub-apps, middleware HTTPException
5051
app.route('/test-errors', errorRoutes);
52+
53+
// Multi-fetch routes: storefront sub-app calls inventoryApp via .request()
54+
app.route('/test-multi-fetch', multiFetchRoutes);
5155
}

0 commit comments

Comments
 (0)