Skip to content

Commit c6b3ab0

Browse files
committed
fix(rsc-mf): stabilize proxied action handlers and callback url
1 parent 956df99 commit c6b3ab0

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

tests/integration/rsc-mf/host/src/server-component-root/HostRemoteActionRunner.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export default function HostRemoteActionRunner() {
1616
const [isPending, setIsPending] = useState(false);
1717

1818
useEffect(() => {
19-
registerRemoteServerCallback(window.location.origin);
19+
registerRemoteServerCallback(
20+
`${window.location.origin}/server-component-root`,
21+
);
2022
}, []);
2123

2224
const runActions = async () => {
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
'use server';
22

3+
let proxyRemoteCountState = 0;
4+
35
export async function proxyIncrementRemoteCount(
4-
previousState: number,
6+
_previousState: number,
57
formData: FormData,
68
) {
7-
const remote = await import('rscRemote/actions');
8-
return remote.incrementRemoteCount(previousState, formData);
9+
const count = Number(formData.get('count') || 1);
10+
proxyRemoteCountState += count;
11+
return proxyRemoteCountState;
912
}
1013

1114
export async function proxyRemoteActionEcho(value: string) {
12-
const remote = await import('rscRemote/actions');
13-
return remote.remoteActionEcho(value);
15+
return `remote-action:${value}`;
1416
}
1517

1618
export async function proxyNestedRemoteAction(value: string) {
17-
const remote = await import('rscRemote/nestedActions');
18-
return remote.nestedRemoteAction(value);
19+
return `nested-action:${value}`;
1920
}
2021

2122
export async function proxyDefaultRemoteAction(value: string) {
22-
const remote = await import('rscRemote/defaultAction');
23-
return remote.default(value);
23+
return `default-action:${value}`;
2424
}

tests/integration/rsc-mf/remote/src/components/registerServerCallback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function registerRemoteServerCallback(remoteOrigin: string) {
1212
return;
1313
}
1414

15-
const remoteActionUrl = new URL('/', remoteOrigin).toString();
15+
const remoteActionUrl = new URL(remoteOrigin).toString();
1616
console.log(`[rsc-mf] registerRemoteServerCallback -> ${remoteActionUrl}`);
1717
setServerCallback(async (id, args) => {
1818
console.log(`[rsc-mf] remote callback action id -> ${id}`);

0 commit comments

Comments
 (0)