( children: ReactNodeList, postponedState: PostponedState, options?: Omit<ResumeOptions, 'nonce'>, )
| 164 | }; |
| 165 | |
| 166 | function resumeAndPrerender( |
| 167 | children: ReactNodeList, |
| 168 | postponedState: PostponedState, |
| 169 | options?: Omit<ResumeOptions, 'nonce'>, |
| 170 | ): Promise<StaticResult> { |
| 171 | return new Promise((resolve, reject) => { |
| 172 | const onFatalError = reject; |
| 173 | |
| 174 | function onAllReady() { |
| 175 | const stream = new ReadableStream( |
| 176 | { |
| 177 | type: 'bytes', |
| 178 | pull: (controller): ?Promise<void> => { |
| 179 | startFlowing(request, controller); |
| 180 | }, |
| 181 | cancel: (reason): ?Promise<void> => { |
| 182 | stopFlowing(request); |
| 183 | abort(request, reason); |
| 184 | }, |
| 185 | }, |
| 186 | // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. |
| 187 | {highWaterMark: 0}, |
| 188 | ); |
| 189 | |
| 190 | const result = { |
| 191 | postponed: getPostponedState(request), |
| 192 | prelude: stream, |
| 193 | }; |
| 194 | resolve(result); |
| 195 | } |
| 196 | |
| 197 | const request = resumeAndPrerenderRequest( |
| 198 | children, |
| 199 | postponedState, |
| 200 | resumeRenderState(postponedState.resumableState, undefined), |
| 201 | options ? options.onError : undefined, |
| 202 | onAllReady, |
| 203 | undefined, |
| 204 | undefined, |
| 205 | onFatalError, |
| 206 | options ? options.onPostpone : undefined, |
| 207 | ); |
| 208 | if (options && options.signal) { |
| 209 | const signal = options.signal; |
| 210 | if (signal.aborted) { |
| 211 | abort(request, (signal: any).reason); |
| 212 | } else { |
| 213 | const listener = () => { |
| 214 | abort(request, (signal: any).reason); |
| 215 | signal.removeEventListener('abort', listener); |
| 216 | }; |
| 217 | signal.addEventListener('abort', listener); |
| 218 | } |
| 219 | } |
| 220 | startWork(request); |
| 221 | }); |
| 222 | } |
| 223 |
nothing calls this directly
no test coverage detected