MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / applyPatches

Function applyPatches

packages/hono/src/shared/applyPatches.ts:27–56  ·  view source on GitHub ↗
(app: Hono<E>)

Source from the content-addressed store, hash-verified

25 * - Retroactively instruments sub-apps mounted before `sentry()` was called.
26 */
27export function applyPatches<E extends Env>(app: Hono<E>): void {
28 // Always call — installRouteHookOnPrototype is idempotent and returns existing handle when prototype already patched
29 _routeHook = installRouteHookOnPrototype();
30
31 // `app.use` (instance own property) — wraps middleware at registration time on this instance.
32 patchAppUse(app);
33
34 // `app.get`, `app.post`, … (instance own properties) — wraps inline middleware (all-but-last handler).
35 patchHttpMethodHandlers(app);
36
37 patchAppRequest(app);
38
39 _routeHook.activate();
40
41 const pendingSubApps = _routeHook.getPendingSubApps();
42
43 if (pendingSubApps.size > 0) {
44 DEBUG_BUILD &&
45 debug.log(
46 `[hono] ${pendingSubApps.size} sub-app(s) were mounted before sentry(). Tracing is applied retroactively. Consider registering sentry() before calling app.route().`,
47 );
48 }
49
50 for (const subApp of pendingSubApps) {
51 wrapSubAppMiddleware(subApp.routes as HonoRoute[]);
52 patchAppRequest(subApp);
53 }
54
55 pendingSubApps.clear();
56}

Callers 6

sentryFunction · 0.90
sentryFunction · 0.90
sentryFunction · 0.90
sentryFunction · 0.90

Calls 7

patchAppUseFunction · 0.90
patchHttpMethodHandlersFunction · 0.90
patchAppRequestFunction · 0.90
wrapSubAppMiddlewareFunction · 0.90
logMethod · 0.65
clearMethod · 0.65

Tested by

no test coverage detected