Commit 99f40b1
committed
fix: handle array/Promise results when wrapping suspended components with markers
`renderToStringAsync` corrupts HTML output when a suspended component's
children produce an Array or Promise result from `_renderToString`. The
suspense marker wrapping code used string concatenation (`+`), which calls
`Array.toString()` on arrays (producing commas) and `[object Promise]` on
unresolved Promises.
This manifests with multi-level cascading suspensions: component A suspends,
and after resolving, its render tree contains components that also suspend
on independent Promises at different times. The `.then()` handler wrapping
A's output receives an Array (from inner elements containing pending Promises)
instead of a string.
Extract a `wrapWithSuspenseMarkers()` helper that handles all three return
types (string, Array, Promise) and use it at both affected call sites:
the try-path `.then()` handler and the catch-path `renderNestedChildren`.
Fixes corrupted SSR output like ",,,,,[object Promise]," in apps using
multi-level suspensions for data fetching.1 parent 449c455 commit 99f40b1
2 files changed
Lines changed: 97 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
37 | 56 | | |
38 | 57 | | |
39 | 58 | | |
| |||
498 | 517 | | |
499 | 518 | | |
500 | 519 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
| 520 | + | |
513 | 521 | | |
514 | 522 | | |
515 | 523 | | |
| |||
556 | 564 | | |
557 | 565 | | |
558 | 566 | | |
559 | | - | |
560 | | - | |
561 | | - | |
| 567 | + | |
562 | 568 | | |
563 | 569 | | |
564 | 570 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
363 | 439 | | |
364 | 440 | | |
365 | 441 | | |
| |||
0 commit comments