Don't outline Suspense boundaries with suspensey CSS during shell flush#545
Don't outline Suspense boundaries with suspensey CSS during shell flush#545everettbu wants to merge 1 commit into
Conversation
When flushing the shell, stylesheets with precedence are emitted in the <head> which blocks paint regardless. Outlining a boundary solely because it has suspensey CSS provides no benefit during the shell flush and causes a higher-level fallback to be shown unnecessarily (e.g. "Middle Fallback" instead of "Inner Fallback"). This change passes a flushingInShell flag to hasSuspenseyContent so the host config can skip stylesheet-only suspensey content when flushing the shell. Suspensey images (used for ViewTransition animation reveals) still trigger outlining during the shell since their motivation is different. When flushing streamed completions the behavior is unchanged — suspensey CSS still causes outlining so the parent content can display sooner while the stylesheet loads.
Greptile SummaryThis PR prevents unnecessary outlining of Suspense boundaries that only contain suspensey CSS (stylesheets with
Confidence Score: 4/5
Important Files Changed
Last reviewed commit: adc3be4 |
| flushingShell = true; | ||
| flushSegment(request, destination, completedRootSegment, null); | ||
| flushingShell = false; |
There was a problem hiding this comment.
Missing finally reset for flushingShell
The sibling module-level flag flushingPartialBoundaries is defensively reset in the finally block (line 5978) to avoid it getting stuck as true if an exception is thrown. The new flushingShell flag follows a similar set/call/reset pattern but lacks the same finally safety net.
If flushSegment were to throw here, flushingShell would remain true for subsequent calls. While this is unlikely to cause real issues in practice (the root segment is flushed once and a throw here likely leaves the stream in a fatal state), adding flushingShell = false to the finally block would be consistent with the existing defensive pattern for flushingPartialBoundaries.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-server/src/ReactFizzServer.js
Line: 5889-5891
Comment:
**Missing `finally` reset for `flushingShell`**
The sibling module-level flag `flushingPartialBoundaries` is defensively reset in the `finally` block (line 5978) to avoid it getting stuck as `true` if an exception is thrown. The new `flushingShell` flag follows a similar set/call/reset pattern but lacks the same `finally` safety net.
If `flushSegment` were to throw here, `flushingShell` would remain `true` for subsequent calls. While this is unlikely to cause real issues in practice (the root segment is flushed once and a throw here likely leaves the stream in a fatal state), adding `flushingShell = false` to the `finally` block would be consistent with the existing defensive pattern for `flushingPartialBoundaries`.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.|
Upstream PR was closed or merged. Code is synced via branch mirror. |
Mirror of facebook/react#35824
Original author: gnoff
When flushing the shell, stylesheets with precedence are emitted in the
<head>which blocks paint regardless. Outlining a boundary solely because it has suspensey CSS provides no benefit during the shell flush and causes a higher-level fallback to be shown unnecessarily (e.g. "Middle Fallback" instead of "Inner Fallback").This change passes a flushingInShell flag to hasSuspenseyContent so the host config can skip stylesheet-only suspensey content when flushing the shell. Suspensey images (used for ViewTransition animation reveals) still trigger outlining during the shell since their motivation is different.
When flushing streamed completions the behavior is unchanged — suspensey CSS still causes outlining so the parent content can display sooner while the stylesheet loads.