You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: skip the switch-locale-path html scan without a link - #4173
switch-locale-path-ssr runs a regex over the whole rendered HTML in app:rendered, on every request. Most pages have no SwitchLocalePathLink, but they still pay for the scan. Vue SSR output has a lot of <!--[--> comments, and each one starts a partial match.
With this change, SwitchLocalePathLink marks its SSR context during setup. The plugin skips the scan when the render has no mark. Pages with the link work as before.
From the repro: a 521 KB page made of 2000 two-root components, Nuxt 4.6.2, i18n 10.6.0, production build. Median of 6 alternating rounds of 2000 requests:
We've flagged this as a potential contribution without a human behind it. We welcome the thoughtful use of AI tools when contributing to Nuxt i18n, but ask all contributors to follow two core principles:
Never let an LLM speak for you - all comments, issues, and PR descriptions should be written in your own words, reflecting your own understanding.
Never let an LLM think for you - only submit contributions you fully understand and can explain.
No actionable comments were generated in the recent review.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: adff70ac-6d27-445d-b13a-dec277615e8f
Commits
Reviewing files that changed from the base of the PR and between 8158ed8 and b239de0.
Files selected for processing: 3
src/runtime/components/SwitchLocalePathLink.ts
src/runtime/plugins/switch-locale-path-ssr.ts
src/runtime/shared/switch-locale-path.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Walkthrough
During server rendering, SwitchLocalePathLinkWrapper marks the Nuxt SSR context when it renders. The SSR locale-path plugin checks whether the context is marked and returns when the HTML is absent or no switch-locale-path link was marked. Otherwise, it continues through the existing replacement logic. The shared module stores marked contexts in a WeakSet.
The optimization safely skips unnecessary scans while preserving rendered locale links.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: skipping the switch-locale-path HTML scan when no link exists.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
No issue. I found this while profiling SSR requests.
Repro with a before and after: https://github.com/onmax/repros/tree/repro/i18n-slp-html-scan/i18n-slp-html-scan (
node verify.mjs && node bench.mjs)📚 Description
switch-locale-path-ssrruns a regex over the whole rendered HTML inapp:rendered, on every request. Most pages have noSwitchLocalePathLink, but they still pay for the scan. Vue SSR output has a lot of<!--[-->comments, and each one starts a partial match.With this change,
SwitchLocalePathLinkmarks its SSR context during setup. The plugin skips the scan when the render has no mark. Pages with the link work as before.From the repro: a 521 KB page made of 2000 two-root components, Nuxt 4.6.2, i18n 10.6.0, production build. Median of 6 alternating rounds of 2000 requests: