Skip to content

Commit 69c9cb7

Browse files
committed
Never parse "then" functions
1 parent f99241b commit 69c9cb7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/react-server/src/ReactFlightReplyServer.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ function loadServerReference<A: Iterable<any>, T>(
437437
if (typeof id !== 'string') {
438438
return (null: any);
439439
}
440+
if (key === 'then') {
441+
// This should never happen because we always serialize objects with then-functions
442+
// as "thenable" which reduces to ReactPromise with no other fields.
443+
return (null: any);
444+
}
440445
const serverReference: ServerReference<T> =
441446
resolveServerReference<$FlowFixMe>(response._bundlerConfig, id);
442447
// We expect most servers to not really need this because you'd just have all
@@ -976,7 +981,17 @@ function extractIterator(response: Response, model: Array<any>): Iterator<any> {
976981
return model[Symbol.iterator]();
977982
}
978983

979-
function createModel(response: Response, model: any): any {
984+
function createModel(
985+
response: Response,
986+
model: any,
987+
parentObject: Object,
988+
key: string,
989+
): any {
990+
if (key === 'then' && typeof model === 'function') {
991+
// This should never happen because we always serialize objects with then-functions
992+
// as "thenable" which reduces to ReactPromise with no other fields.
993+
return null;
994+
}
980995
return model;
981996
}
982997

0 commit comments

Comments
 (0)