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

Function RequestInstance

packages/react-server/src/ReactFlightServer.js:646–775  ·  view source on GitHub ↗
(
  this: $FlowFixMe,
  type: 20 | 21,
  model: ReactClientValue,
  bundlerConfig: ClientManifest,
  onError: void | ((error: mixed) => ?string),
  onPostpone: void | ((reason: string) => void),
  onAllReady: () => void,
  onFatalError: (error: mixed) => void,
  identifierPrefix?: string,
  temporaryReferences: void | TemporaryReferenceSet,
  environmentName: void | string | (() => string), // DEV-only
  filterStackFrame: void | ((url: string, functionName: string) => boolean), // DEV-only
  keepDebugAlive: boolean, // DEV-only
)

Source from the content-addressed store, hash-verified

644const defaultPostponeHandler: (reason: string) => void = noop;
645
646function RequestInstance(
647 this: $FlowFixMe,
648 type: 20 | 21,
649 model: ReactClientValue,
650 bundlerConfig: ClientManifest,
651 onError: void | ((error: mixed) => ?string),
652 onPostpone: void | ((reason: string) => void),
653 onAllReady: () => void,
654 onFatalError: (error: mixed) => void,
655 identifierPrefix?: string,
656 temporaryReferences: void | TemporaryReferenceSet,
657 environmentName: void | string | (() => string), // DEV-only
658 filterStackFrame: void | ((url: string, functionName: string) => boolean), // DEV-only
659 keepDebugAlive: boolean, // DEV-only
660) {
661 if (
662 ReactSharedInternals.A !== null &&
663 ReactSharedInternals.A !== DefaultAsyncDispatcher
664 ) {
665 throw new Error(
666 'Currently React only supports one RSC renderer at a time.',
667 );
668 }
669 ReactSharedInternals.A = DefaultAsyncDispatcher;
670 if (__DEV__) {
671 // Unlike Fizz or Fiber, we don't reset this and just keep it on permanently.
672 // This lets it act more like the AsyncDispatcher so that we can get the
673 // stack asynchronously too.
674 ReactSharedInternals.getCurrentStack = getCurrentStackInDEV;
675 }
676
677 const abortSet: Set<Task> = new Set();
678 const pingedTasks: Array<Task> = [];
679 const cleanupQueue: Array<string | bigint> = [];
680 if (enableTaint) {
681 TaintRegistryPendingRequests.add(cleanupQueue);
682 }
683 const hints = createHints();
684 this.type = type;
685 this.status = OPENING;
686 this.flushScheduled = false;
687 this.fatalError = null;
688 this.destination = null;
689 this.bundlerConfig = bundlerConfig;
690 this.cache = new Map();
691 this.cacheController = new AbortController();
692 this.nextChunkId = 0;
693 this.pendingChunks = 0;
694 this.hints = hints;
695 this.abortableTasks = abortSet;
696 this.pingedTasks = pingedTasks;
697 this.completedImportChunks = ([]: Array<Chunk>);
698 this.completedHintChunks = ([]: Array<Chunk>);
699 this.completedRegularChunks = ([]: Array<Chunk | BinaryChunk>);
700 this.completedErrorChunks = ([]: Array<Chunk>);
701 this.writtenSymbols = new Map();
702 this.writtenClientReferences = new Map();
703 this.writtenServerReferences = new Map();

Callers

nothing calls this directly

Calls 6

createHintsFunction · 0.90
createRootFormatContextFunction · 0.90
emitTimeOriginChunkFunction · 0.85
createTaskFunction · 0.85
addMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected