MCPcopy
hub / github.com/facebook/react / abort

Function abort

packages/react-server/src/ReactFizzServer.js:6286–6320  ·  view source on GitHub ↗
(request: Request, reason: mixed)

Source from the content-addressed store, hash-verified

6284
6285// This is called to early terminate a request. It puts all pending boundaries in client rendered state.
6286export 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
6322export function flushResources(request: Request): void {
6323 enqueueFlush(request);

Callers 15

abortStreamFunction · 0.90
onShellReadyFunction · 0.90
renderToReadableStreamFunction · 0.90
listenerFunction · 0.90
resumeFunction · 0.90
onAllReadyFunction · 0.90
prerenderFunction · 0.90
listenerFunction · 0.90
resumeAndPrerenderFunction · 0.90
prerenderToNodeStreamFunction · 0.90
listenerFunction · 0.90
onAllReadyFunction · 0.90

Calls 7

abortTaskDEVFunction · 0.85
flushCompletedQueuesFunction · 0.85
abortTaskFunction · 0.70
logRecoverableErrorFunction · 0.70
fatalErrorFunction · 0.70
forEachMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected