( request: Request, destination: Destination, )
| 5989 | let flushingPartialBoundaries = false; |
| 5990 | |
| 5991 | function flushCompletedQueues( |
| 5992 | request: Request, |
| 5993 | destination: Destination, |
| 5994 | ): void { |
| 5995 | beginWriting(destination); |
| 5996 | try { |
| 5997 | // The structure of this is to go through each queue one by one and write |
| 5998 | // until the sink tells us to stop. When we should stop, we still finish writing |
| 5999 | // that item fully and then yield. At that point we remove the already completed |
| 6000 | // items up until the point we completed them. |
| 6001 | |
| 6002 | if (request.pendingRootTasks > 0) { |
| 6003 | // When there are pending root tasks we don't want to flush anything |
| 6004 | return; |
| 6005 | } |
| 6006 | |
| 6007 | let i; |
| 6008 | const completedRootSegment = request.completedRootSegment; |
| 6009 | if (completedRootSegment !== null) { |
| 6010 | if (completedRootSegment.status === POSTPONED) { |
| 6011 | return; |
| 6012 | } |
| 6013 | |
| 6014 | const completedPreambleSegments = request.completedPreambleSegments; |
| 6015 | if (completedPreambleSegments === null) { |
| 6016 | // The preamble isn't ready yet even though the root is so we omit flushing |
| 6017 | return; |
| 6018 | } |
| 6019 | |
| 6020 | flushedByteSize = request.byteSize; // Start counting bytes |
| 6021 | // TODO: Count the size of the preamble chunks too. |
| 6022 | let skipBlockingShell = false; |
| 6023 | if (enableFizzBlockingRender) { |
| 6024 | const blockingRenderMaxSize = getBlockingRenderMaxSize(request); |
| 6025 | if (flushedByteSize > blockingRenderMaxSize) { |
| 6026 | skipBlockingShell = true; |
| 6027 | const maxSizeKb = Math.round(blockingRenderMaxSize / 1000); |
| 6028 | const error = new Error( |
| 6029 | 'This rendered a large document (>' + |
| 6030 | maxSizeKb + |
| 6031 | ' kB) without any Suspense ' + |
| 6032 | 'boundaries around most of it. That can delay initial paint longer than ' + |
| 6033 | 'necessary. To improve load performance, add a <Suspense> or <SuspenseList> ' + |
| 6034 | 'around the content you expect to be below the header or below the fold. ' + |
| 6035 | 'In the meantime, the content will deopt to paint arbitrary incomplete ' + |
| 6036 | 'pieces of HTML.', |
| 6037 | ); |
| 6038 | const errorInfo: ThrownInfo = {}; |
| 6039 | logRecoverableError(request, error, errorInfo, null); |
| 6040 | } |
| 6041 | } |
| 6042 | flushPreamble( |
| 6043 | request, |
| 6044 | destination, |
| 6045 | completedRootSegment, |
| 6046 | completedPreambleSegments, |
| 6047 | skipBlockingShell, |
| 6048 | ); |
no test coverage detected