Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions packages/plugin-rsc/e2e/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@

// non-atomic update causes an error
editor.reset()
await expect(page.getByTestId('test-hmr-shared-atomic')).toContainText(

Check failure on line 611 in packages/plugin-rsc/e2e/basic.test.ts

View workflow job for this annotation

GitHub Actions / test-rsc (macos-latest / chromium)

[chromium] › e2e/basic.test.ts:592:5 › dev-default › shared hmr not atomic

1) [chromium] › e2e/basic.test.ts:592:5 › dev-default › shared hmr not atomic ──────────────────── Error: expect(locator).toContainText(expected) failed Locator: getByTestId('test-hmr-shared-atomic') Expected substring: "ErrorBoundary" Received string: "test-hmr-shared-atomic: ok (test-shared)" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByTestId('test-hmr-shared-atomic') 3 × locator resolved to <div data-testid="test-hmr-shared-atomic">…</div> - unexpected value "test-hmr-shared-atomic: ok (test-shared-edit)" 6 × locator resolved to <div data-testid="test-hmr-shared-atomic">…</div> - unexpected value "test-hmr-shared-atomic: ok (test-shared)" 609 | // non-atomic update causes an error 610 | editor.reset() > 611 | await expect(page.getByTestId('test-hmr-shared-atomic')).toContainText( | ^ 612 | 'ErrorBoundary', 613 | ) 614 | at /Users/runner/work/vite-plugin-react/vite-plugin-react/packages/plugin-rsc/e2e/basic.test.ts:611:64
'ErrorBoundary',
)

Expand Down Expand Up @@ -1002,7 +1002,7 @@
'rgb(0, 165, 255)',
)
editor.reset()
await expect(page.locator('.test-style-url-server')).toHaveCSS(

Check failure on line 1005 in packages/plugin-rsc/e2e/basic.test.ts

View workflow job for this annotation

GitHub Actions / test-rsc (macos-latest / chromium)

[chromium] › e2e/basic.test.ts:994:5 › dev-default › css url server hmr

2) [chromium] › e2e/basic.test.ts:994:5 › dev-default › css url server hmr ─────────────────────── Error: expect(locator).toHaveCSS(expected) failed Locator: locator('.test-style-url-server') Expected: "rgb(255, 165, 0)" Received: "rgb(0, 165, 255)" Timeout: 5000ms Call log: - Expect "toHaveCSS" with timeout 5000ms - waiting for locator('.test-style-url-server') 9 × locator resolved to <div class="test-style-url-server">test-style-url-server</div> - unexpected value "rgb(0, 165, 255)" 1003 | ) 1004 | editor.reset() > 1005 | await expect(page.locator('.test-style-url-server')).toHaveCSS( | ^ 1006 | 'color', 1007 | 'rgb(255, 165, 0)', 1008 | ) at /Users/runner/work/vite-plugin-react/vite-plugin-react/packages/plugin-rsc/e2e/basic.test.ts:1005:60
'color',
'rgb(255, 165, 0)',
)
Expand Down Expand Up @@ -1252,8 +1252,7 @@
.click()
}

// TODO: skipped since 19.2.1
test.skip('action bind client @js', async ({ page }) => {
test('action bind client @js', async ({ page }) => {
await page.goto(f.url())
await waitForHydration(page)
await using _ = await expectNoReload(page)
Expand Down Expand Up @@ -1308,10 +1307,7 @@
.click()
}

// TODO: skipped since 19.2.1 as round-tripping server action is broken
// import { createFromReadableStream, renderToReadableStream } from '@vitejs/plugin-rsc/rsc'
// renderToReadableStream -> createFromReadableStream
test.skip('test serialization @js', async ({ page }) => {
test('test serialization @js', async ({ page }) => {
await page.goto(f.url())
await waitForHydration(page)
await expect(page.getByTestId('serialization')).toHaveText('?')
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-rsc/e2e/browser-mode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ function defineBrowserModeTest(f: ReturnType<typeof useFixture>) {
.click()
}

// TODO: skipped since 19.2.1
test.skip('action bind client', async ({ page }) => {
test('action bind client', async ({ page }) => {
await page.goto(f.url())
await testActionBindClient(page)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import { testSerializationAction } from './action'
import { TestSerializationClient } from './client'

export function TestSerializationServer() {
if (1) {
return <div>test-serialization:todo</div>
}
const original = <TestSerializationClient action={testSerializationAction} />
let serialized = renderToReadableStream(original)
// debug serialization
Expand Down
38 changes: 26 additions & 12 deletions packages/plugin-rsc/src/core/rsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,38 @@ export function setRequireModule(options: {
;(globalThis as any).__vite_rsc_server_require__ = memoize(
async (id: string) => {
if (id.startsWith(SERVER_DECODE_CLIENT_PREFIX)) {
// decode client reference on the server
id = id.slice(SERVER_DECODE_CLIENT_PREFIX.length)
id = removeReferenceCacheTag(id)
// create `registerClientReference` on the fly since there's no way to
// grab the original client reference module on ther server.
// cf. https://github.com/lazarv/react-server/blob/79e7acebc6f4a8c930ad8422e2a4a9fdacfcce9b/packages/react-server/server/module-loader.mjs#L19
// decode client reference on the server
return new Proxy({} as any, {
get(target, name, _receiver) {
const target = {} as any
const getOrCreateClientReference = (name: string) => {
return (target[name] ??= ReactServer.registerClientReference(
() => {
throw new Error(
`Unexpectedly client reference export '${name}' is called on server`,
)
},
id,
name,
))
}
return new Proxy(target, {
get(_target, name, _receiver) {
// not thennable
if (typeof name !== 'string' || name === 'then') return
return (target[name] ??= ReactServer.registerClientReference(
() => {
throw new Error(
`Unexpectedly client reference export '${name}' is called on server`,
)
},
id,
name,
))
return getOrCreateClientReference(name)
},
// React 19.2.1+ uses hasOwnProperty.call() to check for exports
// https://github.com/facebook/react/pull/35277
getOwnPropertyDescriptor(_target, name) {
if (typeof name !== 'string' || name === 'then') {
return Reflect.getOwnPropertyDescriptor(target, name)
}
getOrCreateClientReference(name)
return Reflect.getOwnPropertyDescriptor(target, name)
},
})
}
Expand Down
Loading