Commit 9d111ff
authored
Serialize Promises through Flight (#26086)
This lets you pass Promises from server components to client components
and `use()` them there.
We still don't support Promises as children on the client, so we need to
support both. This will be a lot simpler when we remove the need to
encode children as lazy since we don't need the lazy encoding anymore
then.
I noticed that this test failed because we don't synchronously resolve
instrumented Promises if they're lazy. The second fix calls `.then()`
early to ensure that this lazy initialization can happen eagerly. ~It
felt silly to do this with an empty function or something, so I just did
the attachment of ping listeners early here. It's also a little silly
since they will ping the currently running render for no reason if it's
synchronously available.~ EDIT: That didn't work because a ping might
interrupt the current render. Probably need a bigger refactor.
We could add another extension but we've already taken a lot of
liberties with the Promise protocol. At least this is one that doesn't
need extension of the protocol as much. Any sub-class of promises could
do this.1 parent 0ba4698 commit 9d111ff
File tree
4 files changed
+169
-15
lines changed- packages
- react-client/src
- react-reconciler/src
- react-server-dom-webpack/src/__tests__
- react-server/src
4 files changed
+169
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
496 | 502 | | |
497 | 503 | | |
498 | 504 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| |||
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| 113 | + | |
110 | 114 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
| |||
Lines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
905 | 905 | | |
906 | 906 | | |
907 | 907 | | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
908 | 954 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
219 | 295 | | |
220 | 296 | | |
221 | 297 | | |
| |||
270 | 346 | | |
271 | 347 | | |
272 | 348 | | |
| 349 | + | |
273 | 350 | | |
274 | 351 | | |
275 | 352 | | |
| |||
303 | 380 | | |
304 | 381 | | |
305 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
306 | 391 | | |
307 | 392 | | |
308 | 393 | | |
| |||
331 | 416 | | |
332 | 417 | | |
333 | 418 | | |
| 419 | + | |
334 | 420 | | |
335 | 421 | | |
336 | 422 | | |
| |||
345 | 431 | | |
346 | 432 | | |
347 | 433 | | |
| 434 | + | |
348 | 435 | | |
349 | 436 | | |
350 | 437 | | |
| |||
414 | 501 | | |
415 | 502 | | |
416 | 503 | | |
417 | | - | |
| 504 | + | |
418 | 505 | | |
419 | 506 | | |
420 | 507 | | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
421 | 512 | | |
422 | 513 | | |
423 | 514 | | |
| |||
442 | 533 | | |
443 | 534 | | |
444 | 535 | | |
445 | | - | |
| 536 | + | |
446 | 537 | | |
447 | 538 | | |
448 | 539 | | |
| |||
461 | 552 | | |
462 | 553 | | |
463 | 554 | | |
464 | | - | |
| 555 | + | |
465 | 556 | | |
466 | 557 | | |
467 | 558 | | |
| |||
835 | 926 | | |
836 | 927 | | |
837 | 928 | | |
| 929 | + | |
838 | 930 | | |
839 | 931 | | |
840 | 932 | | |
| |||
873 | 965 | | |
874 | 966 | | |
875 | 967 | | |
876 | | - | |
| 968 | + | |
877 | 969 | | |
878 | 970 | | |
879 | 971 | | |
| |||
887 | 979 | | |
888 | 980 | | |
889 | 981 | | |
890 | | - | |
| 982 | + | |
891 | 983 | | |
892 | 984 | | |
893 | 985 | | |
| |||
899 | 991 | | |
900 | 992 | | |
901 | 993 | | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
902 | 999 | | |
903 | 1000 | | |
904 | 1001 | | |
| |||
1157 | 1254 | | |
1158 | 1255 | | |
1159 | 1256 | | |
| 1257 | + | |
1160 | 1258 | | |
1161 | 1259 | | |
1162 | 1260 | | |
| |||
1180 | 1278 | | |
1181 | 1279 | | |
1182 | 1280 | | |
| 1281 | + | |
1183 | 1282 | | |
1184 | 1283 | | |
1185 | 1284 | | |
| |||
0 commit comments