Repository navigation
fix(client): skip rewriting unchanged adopted styles - #23697
Merged
Merged
Conversation
`updateStyle` reuses a server-rendered `<style data-vite-dev-id>` and then sets its `textContent` to the module's CSS, even when the text is already the same. Chrome 154 replaces the stylesheet on that write and re-creates the font faces it declares. Those fonts are then revalidated, since the dev server serves them with `Cache-Control: no-cache`, and a `font-display: optional` font that is still loading when the page renders stays on its fallback. Only write the CSS when it differs.
commented
Oct 8, 2026
Member
|
It seems this is related to https://chromium-review.googlesource.com/c/chromium/src/+/8252693. But regardless of that, I think it's good to have this change. |
sapphi-red
approved these changes
Oct 8, 2026
This was referenced Oct 8, 2026
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fixes #23696
When the dev client reuses a server-rendered
<style data-vite-dev-id>,updateStylewrites the module's CSS into it even if it's the same text. In Chrome 154 that replaces the stylesheet and re-creates its@font-facerules, the fonts get revalidated, and afont-display: optionalfont that's still loading at render time falls back for good.This only writes when the text is different. HMR updates that change the CSS work as before. One thing that changes: if something edited the stylesheet through the CSSOM, an update with the same text no longer resets it.
For the test I added a
css-stylepage to thehmrplayground, next tocss-link. A small plugin renders the<style data-vite-dev-id>the way an SSR framework would, and a script counts mutations of that style. The test checks that loading the module leaves the style alone (one style, zero mutations) and that editing the file still updates it. Without the fix it gets[1, 1]. Because it counts mutations, it also catches the rewrite in Playwright's Chromium, where the font symptom itself doesn't show.I used an AI assistant while investigating and drafting this. I reviewed the change myself: I read
updateStyleand ran the new test without the fix (fails with[1, 1]) and with it (passes).