( request: Request, task: ReplayTask, children: Array<any>, childIndex: number, )
| 3600 | } |
| 3601 | |
| 3602 | function replayFragment( |
| 3603 | request: Request, |
| 3604 | task: ReplayTask, |
| 3605 | children: Array<any>, |
| 3606 | childIndex: number, |
| 3607 | ): void { |
| 3608 | // If we're supposed follow this array, we'd expect to see a ReplayNode matching |
| 3609 | // this fragment. |
| 3610 | const replay = task.replay; |
| 3611 | const replayNodes = replay.nodes; |
| 3612 | for (let j = 0; j < replayNodes.length; j++) { |
| 3613 | const node = replayNodes[j]; |
| 3614 | if (node[1] !== childIndex) { |
| 3615 | continue; |
| 3616 | } |
| 3617 | // Matched a replayable path. |
| 3618 | const childNodes = node[2]; |
| 3619 | const childSlots = node[3]; |
| 3620 | task.replay = {nodes: childNodes, slots: childSlots, pendingTasks: 1}; |
| 3621 | try { |
| 3622 | renderChildrenArray(request, task, children, -1); |
| 3623 | if (task.replay.pendingTasks === 1 && task.replay.nodes.length > 0) { |
| 3624 | throw new Error( |
| 3625 | "Couldn't find all resumable slots by key/index during replaying. " + |
| 3626 | "The tree doesn't match so React will fallback to client rendering.", |
| 3627 | ); |
| 3628 | } |
| 3629 | task.replay.pendingTasks--; |
| 3630 | } catch (x) { |
| 3631 | if ( |
| 3632 | typeof x === 'object' && |
| 3633 | x !== null && |
| 3634 | (x === SuspenseException || typeof x.then === 'function') |
| 3635 | ) { |
| 3636 | // Suspend |
| 3637 | throw x; |
| 3638 | } |
| 3639 | task.replay.pendingTasks--; |
| 3640 | // Unlike regular render, we don't terminate the siblings if we error |
| 3641 | // during a replay. That's because this component didn't actually error |
| 3642 | // in the original prerender. What's unable to complete is the child |
| 3643 | // replay nodes which might be Suspense boundaries which are able to |
| 3644 | // absorb the error and we can still continue with siblings. |
| 3645 | // This is an error, stash the component stack if it is null. |
| 3646 | const thrownInfo = getThrownInfo(task.componentStack); |
| 3647 | erroredReplay( |
| 3648 | request, |
| 3649 | task.blockedBoundary, |
| 3650 | x, |
| 3651 | thrownInfo, |
| 3652 | childNodes, |
| 3653 | childSlots, |
| 3654 | __DEV__ ? task.debugTask : null, |
| 3655 | ); |
| 3656 | } |
| 3657 | task.replay = replay; |
| 3658 | // We finished rendering this node, so now we can consume this |
| 3659 | // slot. This must happen after in case we rerender this task. |
no test coverage detected