perf: skip i18n context setup for build asset requests - #4145
Conversation
7e081ed to
d53377d
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review. WalkthroughThe server plugin derives the build-assets path from runtime configuration and skips i18n context initialization for matching requests. New tests cover default and base URLs, page requests, and root asset paths. Test mocks, Vitest aliases, and a global stub support isolated server-plugin testing. Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This localized performance change avoids unnecessary i18n setup for build asset requests without identified functional impact; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
d53377d to
f863974
Compare
The nitro
requesthook sets up the i18n context for every request, including the/_nuxt/*chunks a node-server deployment serves itself. That setup callsuseRuntimeConfig(event), which clones the whole runtime config and walks every key looking for env overrides, so a 442-byte JS chunk pays for a full config pass it never reads. The reporter profiled it at ~16.5% of non-idle CPU, with throughput dropping from ~9060 rps on Nuxt 3.15 + i18n 9.5.6 to ~2065 rps on 10.6.0.The hook now returns early for paths under
app.buildAssetsDir, resolved once during plugin setup. Nothing downstream reads the context on that path: nitro serves or 404s build assets beforerender:beforeruns, souseI18nContextis never reached for them. The reporter measured ~8290 rps with the same guard, and SSR requests are unaffected.Summary by CodeRabbit
Bug Fixes
Tests