-
-
Notifications
You must be signed in to change notification settings - Fork 188
fix(rsc): propagate client reference invalidation to server #788
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
hi-ogawa
merged 7 commits into
main
from
08-27-fix_rsc_propagate_client_reference_invalidation_to_server
Aug 28, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bf94a13
fix(rsc): propagate client reference invalidation to server
hi-ogawa 139a653
fix: wip
hi-ogawa da11904
test: e2e
hi-ogawa ff965c6
wip
hi-ogawa 3ef4ae4
chore: cleanup
hi-ogawa 3fa81ab
test: more
hi-ogawa 5058fa3
test: more example
hi-ogawa 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
3 changes: 3 additions & 0 deletions
3
packages/plugin-rsc/examples/basic/src/routes/hmr-client-dep2/client-dep.ts
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,3 @@ | ||
export function clientDep() { | ||
return '[ok]' | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/plugin-rsc/examples/basic/src/routes/hmr-client-dep2/client.tsx
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,24 @@ | ||
'use client' | ||
|
||
import React from 'react' | ||
import { clientDep } from './client-dep' | ||
|
||
export function TestHmrClientDep2(props: { url: Pick<URL, 'search'> }) { | ||
const [count, setCount] = React.useState(0) | ||
return ( | ||
<div> | ||
<span data-testid="test-hmr-client-dep2"> | ||
<button onClick={() => setCount((c) => c + 1)}> | ||
test-hmr-client-dep2: {count} | ||
</button> | ||
{clientDep()} | ||
</span>{' '} | ||
<a href="?test-hmr-client-dep2-re-render"> | ||
re-render | ||
{props.url.search.includes('test-hmr-client-dep2-re-render') | ||
? ' [ok]' | ||
: ''} | ||
</a> | ||
</div> | ||
) | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/plugin-rsc/examples/basic/src/routes/hmr-client-dep3/client-a.tsx
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,20 @@ | ||
'use client' | ||
|
||
import React from 'react' | ||
import { clientDep } from './client-dep' | ||
import { ClientDepComp } from './client-dep-comp' | ||
|
||
export function TestHmrClientDepA() { | ||
const [count, setCount] = React.useState(0) | ||
return ( | ||
<> | ||
<span data-testid="test-hmr-client-dep3"> | ||
<button onClick={() => setCount((c) => c + 1)}> | ||
test-hmr-client-dep3: {count} | ||
</button> | ||
{clientDep()} | ||
<ClientDepComp /> | ||
</span> | ||
</> | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/plugin-rsc/examples/basic/src/routes/hmr-client-dep3/client-b.tsx
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,7 @@ | ||
'use client' | ||
|
||
import { TestHmrClientDepA } from './client-a' | ||
|
||
export function TestHmrClientDepB() { | ||
return <TestHmrClientDepA /> | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/plugin-rsc/examples/basic/src/routes/hmr-client-dep3/client-dep-comp.tsx
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,3 @@ | ||
export function ClientDepComp() { | ||
return '[ok]' | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/plugin-rsc/examples/basic/src/routes/hmr-client-dep3/client-dep.ts
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,3 @@ | ||
export function clientDep() { | ||
return '[ok]' | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/plugin-rsc/examples/basic/src/routes/hmr-client-dep3/server.tsx
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,23 @@ | ||
import { TestHmrClientDepA } from './client-a' | ||
import { TestHmrClientDepB } from './client-b' | ||
|
||
// example to demonstrate a folowing behavior | ||
// https://github.com/vitejs/vite-plugin-react/pull/788#issuecomment-3227656612 | ||
/* | ||
server server | ||
| | | ||
v v | ||
client-a client-a?t=xx <-- client-b | ||
| | | ||
v v | ||
client-dep-comp?t=xx | ||
*/ | ||
|
||
export function TestHmrClientDep3() { | ||
return ( | ||
<div> | ||
<TestHmrClientDepA /> | ||
<TestHmrClientDepB /> | ||
</div> | ||
) | ||
} |
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
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.
Since this only covers the case where client boundary gets hmr-ed, technically there are edge cases like client reference itself doesn't self-accept or
invalidateModule
is directly used, so they causes full-reload instead.Uh oh!
There was an error while loading. Please reload this page.
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.
However, patching
invalidateModule
directly will break the first test case "non-client-reference client hmr" as this is more aggressive invalidation.