(request: Request, reason: mixed)
| 6284 | |
| 6285 | // This is called to early terminate a request. It puts all pending boundaries in client rendered state. |
| 6286 | export function abort(request: Request, reason: mixed): void { |
| 6287 | if (request.status === OPEN || request.status === OPENING) { |
| 6288 | request.status = ABORTING; |
| 6289 | } |
| 6290 | |
| 6291 | try { |
| 6292 | const abortableTasks = request.abortableTasks; |
| 6293 | if (abortableTasks.size > 0) { |
| 6294 | const error = |
| 6295 | reason === undefined |
| 6296 | ? new Error('The render was aborted by the server without a reason.') |
| 6297 | : typeof reason === 'object' && |
| 6298 | reason !== null && |
| 6299 | typeof reason.then === 'function' |
| 6300 | ? new Error('The render was aborted by the server with a promise.') |
| 6301 | : reason; |
| 6302 | // This error isn't necessarily fatal in this case but we need to stash it |
| 6303 | // so we can use it to abort any pending work |
| 6304 | request.fatalError = error; |
| 6305 | if (__DEV__) { |
| 6306 | abortableTasks.forEach(task => abortTaskDEV(task, request, error)); |
| 6307 | } else { |
| 6308 | abortableTasks.forEach(task => abortTask(task, request, error)); |
| 6309 | } |
| 6310 | abortableTasks.clear(); |
| 6311 | } |
| 6312 | if (request.destination !== null) { |
| 6313 | flushCompletedQueues(request, request.destination); |
| 6314 | } |
| 6315 | } catch (error) { |
| 6316 | const errorInfo: ThrownInfo = {}; |
| 6317 | logRecoverableError(request, error, errorInfo, null); |
| 6318 | fatalError(request, error, errorInfo, null); |
| 6319 | } |
| 6320 | } |
| 6321 | |
| 6322 | export function flushResources(request: Request): void { |
| 6323 | enqueueFlush(request); |
no test coverage detected