88
hoistHoistables,
89
createHoistableState,
90
createPreambleState,
91
+ isWorkLoopExternallyDriven,
92
supportsRequestStorage,
93
requestStorage,
94
pushFormStateMarkerIsMatching,
528
progressiveChunkSize === undefined
529
? DEFAULT_PROGRESSIVE_CHUNK_SIZE
530
: progressiveChunkSize;
530
- this.status = OPENING;
531
+ this.status = isWorkLoopExternallyDriven ? OPEN : OPENING;
532
this.fatalError = null;
533
this.nextSegmentId = 0;
534
this.allPendingTasks = 0;
791
function pingTask(request: Request, task: Task): void {
792
const pingedTasks = request.pingedTasks;
793
pingedTasks.push(task);
793
- if (request.pingedTasks.length === 1) {
794
- request.flushScheduled = request.destination !== null;
795
- if (request.trackedPostpones !== null || request.status === OPENING) {
796
- scheduleMicrotask(() => performWork(request));
797
- } else {
798
- scheduleWork(() => performWork(request));
794
+ if (isWorkLoopExternallyDriven) {
795
+ return;
796
+ } else {
797
+ if (request.pingedTasks.length === 1) {
798
+ request.flushScheduled = request.destination !== null;
799
+ if (request.trackedPostpones !== null || request.status === OPENING) {
800
+ scheduleMicrotask(() => performWork(request));
801
+ } else {
802
+ scheduleWork(() => performWork(request));
803
+ }
804
}
805
}
806
}
6035
}
6036
6037
export function startWork(request: Request): void {
6033
- request.flushScheduled = request.destination !== null;
6034
- // When prerendering we use microtasks for pinging work
6035
- if (supportsRequestStorage) {
6036
- scheduleMicrotask(() => requestStorage.run(request, performWork, request));
6038
+ if (isWorkLoopExternallyDriven) {
6039
+ return;
6040
} else {
6038
- scheduleMicrotask(() => performWork(request));
6039
- }
6040
- scheduleWork(() => {
6041
- if (request.status === OPENING) {
6042
- request.status = OPEN;
6043
- }
6044
-
6045
- if (request.trackedPostpones === null) {
6046
- // this is either a regular render or a resume. For regular render we want
6047
- // to call emitEarlyPreloads after the first performWork because we want
6048
- // are responding to a live request and need to balance sending something early
6049
- // (i.e. don't want for the shell to finish) but we need something to send.
6050
- // The only implementation of this is for DOM at the moment and during resumes nothing
6051
- // actually emits but the code paths here are the same.
6052
- // During a prerender we don't want to be too aggressive in emitting early preloads
6053
- // because we aren't responding to a live request and we can wait for the prerender to
6054
- // postpone before we emit anything.
6055
- if (supportsRequestStorage) {
6056
- requestStorage.run(
6057
- request,
6058
- enqueueEarlyPreloadsAfterInitialWork,
6059
- request,
6060
- );
6061
- } else {
6062
- enqueueEarlyPreloadsAfterInitialWork(request);
6063
- }
6041
+ request.flushScheduled = request.destination !== null;
6042
+ // When prerendering we use microtasks for pinging work
6043
+ if (supportsRequestStorage) {
6044
+ scheduleMicrotask(() =>
6045
+ requestStorage.run(request, performWork, request),
6046
+ );
6047
+ } else {
6048
+ scheduleMicrotask(() => performWork(request));
6049
}
6065
- });
6050
+ scheduleWork(() => {
6051
+ if (request.status === OPENING) {
6052
+ request.status = OPEN;
6053
+ }
6054
+
6055
+ if (request.trackedPostpones === null) {
6056
+ // this is either a regular render or a resume. For regular render we want
6057
+ // to call emitEarlyPreloads after the first performWork because we want
6058
+ // are responding to a live request and need to balance sending something early
6059
+ // (i.e. don't want for the shell to finish) but we need something to send.
6060
+ // The only implementation of this is for DOM at the moment and during resumes nothing
6061
+ // actually emits but the code paths here are the same.
6062
+ // During a prerender we don't want to be too aggressive in emitting early preloads
6063
+ // because we aren't responding to a live request and we can wait for the prerender to
6064
+ // postpone before we emit anything.
6065
+ if (supportsRequestStorage) {
6066
+ requestStorage.run(
6067
+ request,
6068
+ enqueueEarlyPreloadsAfterInitialWork,
6069
+ request,
6070
+ );
6071
+ } else {
6072
+ enqueueEarlyPreloadsAfterInitialWork(request);
6073
+ }
6074
+ }
6075
+ });
6076
+ }
6077
}
6078
6079
function enqueueEarlyPreloadsAfterInitialWork(request: Request) {