Skip to content

Commit 6871db7

Browse files
committed
refactor(rsc-mf): stabilize remote callback registration keying
1 parent cf1e7fb commit 6871db7

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ import {
66
} from 'rsc-mf-react-server-dom-client-browser';
77

88
let registeredCallbackKey = '';
9+
const getStableProxyActionIdEntries = (
10+
remoteActionIdToHostProxyActionId?: Record<string, string>,
11+
) =>
12+
Object.entries(remoteActionIdToHostProxyActionId ?? {}).sort(
13+
([left], [right]) => left.localeCompare(right),
14+
);
15+
916
const getHostActionId = (rawActionId: string, remoteAlias: string) => {
1017
if (rawActionId.startsWith('remote:')) {
1118
return rawActionId;
@@ -25,7 +32,9 @@ export function registerRemoteServerCallback(
2532
const callbackKey = JSON.stringify({
2633
remoteAlias,
2734
remoteOrigin,
28-
remoteActionIdToHostProxyActionId,
35+
remoteActionIdToHostProxyActionId: getStableProxyActionIdEntries(
36+
remoteActionIdToHostProxyActionId,
37+
),
2938
});
3039
if (registeredCallbackKey === callbackKey) {
3140
return;

0 commit comments

Comments
 (0)