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

Function startWork

packages/react-server/src/ReactFizzServer.js:6172–6206  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

6170}
6171
6172export function startWork(request: Request): void {
6173 request.flushScheduled = request.destination !== null;
6174 // When prerendering we use microtasks for pinging work
6175 if (supportsRequestStorage) {
6176 scheduleMicrotask(() => requestStorage.run(request, performWork, request));
6177 } else {
6178 scheduleMicrotask(() => performWork(request));
6179 }
6180 scheduleWork(() => {
6181 if (request.status === OPENING) {
6182 request.status = OPEN;
6183 }
6184
6185 if (request.trackedPostpones === null) {
6186 // this is either a regular render or a resume. For regular render we want
6187 // to call emitEarlyPreloads after the first performWork because we want
6188 // are responding to a live request and need to balance sending something early
6189 // (i.e. don't want for the shell to finish) but we need something to send.
6190 // The only implementation of this is for DOM at the moment and during resumes nothing
6191 // actually emits but the code paths here are the same.
6192 // During a prerender we don't want to be too aggressive in emitting early preloads
6193 // because we aren't responding to a live request and we can wait for the prerender to
6194 // postpone before we emit anything.
6195 if (supportsRequestStorage) {
6196 requestStorage.run(
6197 request,
6198 enqueueEarlyPreloadsAfterInitialWork,
6199 request,
6200 );
6201 } else {
6202 enqueueEarlyPreloadsAfterInitialWork(request);
6203 }
6204 }
6205 });
6206}
6207
6208function enqueueEarlyPreloadsAfterInitialWork(request: Request) {
6209 const shellComplete = request.pendingRootTasks === 0;

Callers 15

renderToStreamFunction · 0.90
renderToReadableStreamFunction · 0.90
resumeFunction · 0.90
prerenderFunction · 0.90
resumeAndPrerenderFunction · 0.90
prerenderToNodeStreamFunction · 0.90
prerenderFunction · 0.90
resumeAndPrerenderFunction · 0.90
renderToReadableStreamFunction · 0.90
renderToReadableStreamFunction · 0.90
resumeFunction · 0.90

Calls 5

scheduleMicrotaskFunction · 0.90
scheduleWorkFunction · 0.90
runMethod · 0.80
performWorkFunction · 0.70

Tested by

no test coverage detected