-
Notifications
You must be signed in to change notification settings - Fork 31.5k
[turbopack] Don't SSR on pages only navigated to through a soft nav #95539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sampoder
merged 3 commits into
canary
from
sp/turbopack/disable-ssr-in-dev-flight/skip-ssr-on-navigation
Jul 17, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| use anyhow::Result; | ||
| use bincode::{Decode, Encode}; | ||
| use rustc_hash::FxHashSet; | ||
| use turbo_rcstr::RcStr; | ||
| use turbo_tasks::{ | ||
| NonLocalValue, OperationVc, ResolvedVc, State, Vc, debug::ValueDebugFormat, trace::TraceRawVcs, | ||
| }; | ||
|
|
||
| use crate::{app::mark_as_ssr_operation, operation::OptionEndpoint}; | ||
|
|
||
| #[turbo_tasks::value] | ||
| pub struct OutputModeState { | ||
| /// App pages that must emit full HTML output, including Client Component | ||
| /// SSR chunks. Insert-only: once a page has been rendered as a document it | ||
| /// never downgrades to the SSR-free output. | ||
| ssr_pages: State<FxHashSet<RcStr>>, | ||
| } | ||
|
|
||
| impl OutputModeState { | ||
| /// This must not be a `#[turbo_tasks::function]` because it should be a | ||
| /// singleton for each project. | ||
| pub fn new() -> ResolvedVc<Self> { | ||
| OutputModeState { | ||
| ssr_pages: State::new(FxHashSet::default()), | ||
| } | ||
| .resolved_cell() | ||
| } | ||
|
|
||
| fn mark_ssr(&self, page: RcStr) { | ||
| self.ssr_pages | ||
| .update_conditionally(|pages| pages.insert(page)); | ||
| } | ||
| } | ||
|
|
||
| #[turbo_tasks::value_impl] | ||
| impl OutputModeState { | ||
| #[turbo_tasks::function] | ||
| pub fn is_ssr_page(&self, page: RcStr) -> Vc<bool> { | ||
| Vc::cell(self.ssr_pages.get().contains(&page)) | ||
| } | ||
| } | ||
|
|
||
| #[turbo_tasks::value(transparent)] | ||
| pub struct OptionOutputModeState(Option<ResolvedVc<OutputModeState>>); | ||
|
|
||
| #[derive( | ||
| TraceRawVcs, PartialEq, Eq, ValueDebugFormat, Clone, Debug, NonLocalValue, Encode, Decode, | ||
| )] | ||
| pub struct SsrMarkTarget { | ||
| pub state: ResolvedVc<OutputModeState>, | ||
| pub page: RcStr, | ||
| } | ||
|
|
||
| #[turbo_tasks::value(transparent)] | ||
| pub struct OptionSsrMarkTarget(Option<SsrMarkTarget>); | ||
|
|
||
| /// Marks the app page served by `endpoint_op` as requiring full HTML output | ||
| /// from now on. No-op for endpoints other than app page HTML endpoints. | ||
| pub async fn mark_as_ssr(endpoint_op: OperationVc<OptionEndpoint>) -> Result<()> { | ||
| let target = mark_as_ssr_operation(endpoint_op) | ||
| .read_strongly_consistent() | ||
| .await?; | ||
| if let Some(target) = &*target { | ||
| target.state.await?.mark_ssr(target.page.clone()); | ||
| } | ||
| Ok(()) | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we always resolve the chunking context if we might not need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're still using this for RSC