Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 9c681bf

Browse files
committed
fix: move error handlers to mountedRouter for proper execution (#1165)
1 parent 7611b68 commit 9c681bf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/core/src/manager/router.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,6 @@ export function createManagerRouter(
781781
router as unknown as Hono,
782782
);
783783

784-
router.notFound(handleRouteNotFound);
785-
router.onError(handleRouteError.bind(undefined, {}));
786784

787785
// Mount on both / and /registry
788786
//
@@ -796,6 +794,10 @@ export function createManagerRouter(
796794
mountedRouter.route("/", router);
797795
mountedRouter.route("/registry", router);
798796

797+
// IMPORTANT: These must be on `mountedRouter` instead of `router` or else they will not be called.
798+
mountedRouter.notFound(handleRouteNotFound);
799+
mountedRouter.onError(handleRouteError.bind(undefined, {}));
800+
799801
return { router: mountedRouter, openapi: router };
800802
}
801803

0 commit comments

Comments
 (0)