fix: revert OpenAPIHono generics from routes/index.ts (OOM)#2270
fix: revert OpenAPIHono generics from routes/index.ts (OOM)#2270andrew-bierman wants to merge 2 commits into
Conversation
Adding <Bindings/Variables> to the three OpenAPIHono instances in the runtime router causes TypeScript to OOM (~8 GB heap) — the same instantiation-depth issue that motivated the separate rpcRoutes pattern. The runtime router doesn't need explicit generics since its type is not exported as AppType. https://claude.ai/code/session_01JtEqZjLSh3kkycRSrrF3f5
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for Expo Unit Tests Coverage (./apps/expo)
File CoverageNo changed files found. |
Coverage Report for API Unit Tests Coverage (./packages/api)
File CoverageNo changed files found. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
packrat-admin | a2ef411 | Apr 22 2026, 12:30 PM |
There was a problem hiding this comment.
Pull request overview
This PR reverts explicit OpenAPIHono<{ Bindings: Env; Variables: Variables }> generics in the top-level route composition to avoid TypeScript instantiation-depth/heap blowups that lead to OOM during type-checking, aligning with the existing rpcRoutes pattern used for hc<AppType> inference.
Changes:
- Remove
Env/Variablestype imports and dropOpenAPIHonogeneric parameters inpackages/api/src/routes/index.ts. - Simplify
publicRoutesandroutesconstruction while keeping the same routing structure.
Comments suppressed due to low confidence (1)
packages/api/src/routes/index.ts:45
- The JSDoc here says this routes type is used by
hc<AppRoutes>(), but the repo’s api client currently useshc<AppType>exported frompackages/api/src/index.ts. Please update/remove this comment (and consider dropping theAppRoutesexport if it’s no longer used) to avoid confusion and reduce TS type surface area.
const routes = $(new OpenAPIHono().route('/', publicRoutes).route('/', protectedRoutes));
export { routes };
/** Full type of the PackRat Hono app — used by `hc<AppRoutes>()` in api-client. */
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .route('/auth', authRoutes) | ||
| .route('/admin', adminRoutes), | ||
| ); | ||
| const publicRoutes = $(new OpenAPIHono().route('/auth', authRoutes).route('/admin', adminRoutes)); |
There was a problem hiding this comment.
This line is >100 chars (repo Biome lineWidth is 100) and will likely fail biome check formatting. Please reformat back to a multi-line chain (or run biome format) to keep it within the formatter’s wrapping rules.
| const publicRoutes = $(new OpenAPIHono().route('/auth', authRoutes).route('/admin', adminRoutes)); | |
| const publicRoutes = $( | |
| new OpenAPIHono() | |
| .route('/auth', authRoutes) | |
| .route('/admin', adminRoutes), | |
| ); |
| .route('/', publicRoutes) | ||
| .route('/', protectedRoutes), | ||
| ); | ||
| const routes = $(new OpenAPIHono().route('/', publicRoutes).route('/', protectedRoutes)); |
There was a problem hiding this comment.
This chained call is also over the 100-char formatter line width and is likely to trigger a formatting failure in biome check. Reformat to the multi-line style used elsewhere in this file (or run biome format).
| const routes = $(new OpenAPIHono().route('/', publicRoutes).route('/', protectedRoutes)); | |
| const routes = $( | |
| new OpenAPIHono().route('/', publicRoutes).route('/', protectedRoutes), | |
| ); |
AppRoutes was superseded by AppType in packages/api/src/index.ts. Lines kept single-line as Biome prefers (both fit within 100 chars). https://claude.ai/code/session_01JtEqZjLSh3kkycRSrrF3f5
Summary
<{ Bindings: Env; Variables: Variables }>generics that were added to the threeOpenAPIHonoinstances inroutes/index.tsin ✨ add Hono RPC foundation #2268Adding those generics causes TypeScript to exhaust ~8 GB of heap and OOM. This is the same instantiation-depth explosion that motivated the separate
rpcRoutespattern — the runtime router's type is never exported asAppType, so the generics serve no purpose there and should not be present.Test plan
bun run check-typesinpackages/apicompletes without OOM