@samitouri / QOS-React-2 / commits / 556644e237

Fix plurals (#21106)

Sebastian Markbåge committed Mar 25, 2021 at 22:21 UTC 556644e2372bf275a498006fc17dff14d324d6be
1 file changed +27 -27
packages/react-server/src/ReactFizzServer.js
+27 -27
@@ -62,7 +62,7 @@ type SuspenseBoundary = {
62 pendingTasks: number, // when it reaches zero we can show this boundary's content
63 completedSegments: Array<Segment>, // completed but not yet flushed segments.
64 byteSize: number, // used to determine whether to inline children boundaries.
65 - fallbackAbortableTask: Set<Task>, // used to cancel task on the fallback if the boundary completes or gets canceled.
65 + fallbackAbortableTasks: Set<Task>, // used to cancel task on the fallback if the boundary completes or gets canceled.
66 };
67
68 type Task = {
@@ -107,8 +107,8 @@ type Request = {
107 allPendingTasks: number, // when it reaches zero, we can close the connection.
108 pendingRootTasks: number, // when this reaches zero, we've finished at least the root boundary.
109 completedRootSegment: null | Segment, // Completed but not yet flushed root segments.
110 - abortableTask: Set<Task>,
111 - pingedTask: Array<Task>,
110 + abortableTasks: Set<Task>,
111 + pingedTasks: Array<Task>,
112 // Queues to flush in order of priority
113 clientRenderedBoundaries: Array<SuspenseBoundary>, // Errored or client rendered but not yet flushed.
114 completedBoundaries: Array<SuspenseBoundary>, // Completed but not yet fully flushed boundaries to show.
@@ -151,7 +151,7 @@ export function createRequest(
151 onCompleteAll: () => void = noop,
152 onReadyToStream: () => void = noop,
153 ): Request {
154 - const pingedTask = [];
154 + const pingedTasks = [];
155 const abortSet: Set<Task> = new Set();
156 const request = {
157 destination,
@@ -162,8 +162,8 @@ export function createRequest(
162 allPendingTasks: 0,
163 pendingRootTasks: 0,
164 completedRootSegment: null,
165 - abortableTask: abortSet,
166 - pingedTask: pingedTask,
165 + abortableTasks: abortSet,
166 + pingedTasks: pingedTasks,
167 clientRenderedBoundaries: [],
168 completedBoundaries: [],
169 partialBoundaries: [],
@@ -184,21 +184,21 @@ export function createRequest(
184 rootContext,
185 null,
186 );
187 - pingedTask.push(rootTask);
187 + pingedTasks.push(rootTask);
188 return request;
189 }
190
191 function pingTask(request: Request, task: Task): void {
192 - const pingedTask = request.pingedTask;
193 - pingedTask.push(task);
194 - if (pingedTask.length === 1) {
192 + const pingedTasks = request.pingedTasks;
193 + pingedTasks.push(task);
194 + if (pingedTasks.length === 1) {
195 scheduleWork(() => performWork(request));
196 }
197 }
198
199 function createSuspenseBoundary(
200 request: Request,
201 - fallbackAbortableTask: Set<Task>,
201 + fallbackAbortableTasks: Set<Task>,
202 ): SuspenseBoundary {
203 return {
204 id: createSuspenseBoundaryID(request.responseState),
@@ -208,7 +208,7 @@ function createSuspenseBoundary(
208 forceClientRender: false,
209 completedSegments: [],
210 byteSize: 0,
211 - fallbackAbortableTask,
211 + fallbackAbortableTasks,
212 };
213 }
214
@@ -385,7 +385,7 @@ function renderNode(request: Request, task: Task, node: ReactNodeList): void {
385 // no parent segment so there's nothing to wait on.
386 contentRootSegment.parentFlushed = true;
387
388 - // Currently this is running synchronously. We could instead schedule this to pingedTask.
388 + // Currently this is running synchronously. We could instead schedule this to pingedTasks.
389 // I suspect that there might be some efficiency benefits from not creating the suspended task
390 // and instead just using the stack if possible.
391 // TODO: Call this directly instead of messing with saving and restoring contexts.
@@ -430,7 +430,7 @@ function renderNode(request: Request, task: Task, node: ReactNodeList): void {
430 );
431 // TODO: This should be queued at a separate lower priority queue so that we only task
432 // on preparing fallbacks if we don't have any more main content to task on.
433 - request.pingedTask.push(suspendedFallbackTask);
433 + request.pingedTasks.push(suspendedFallbackTask);
434 } else {
435 throw new Error('Not yet implemented element type.');
436 }
@@ -501,8 +501,8 @@ function abortTask(task: Task): void {
501
502 // If this boundary was still pending then we haven't already cancelled its fallbacks.
503 // We'll need to abort the fallbacks, which will also error that parent boundary.
504 - boundary.fallbackAbortableTask.forEach(abortTask, request);
505 - boundary.fallbackAbortableTask.clear();
504 + boundary.fallbackAbortableTasks.forEach(abortTask, request);
505 + boundary.fallbackAbortableTasks.clear();
506
507 if (!boundary.forceClientRender) {
508 boundary.forceClientRender = true;
@@ -541,8 +541,8 @@ function finishedTask(
541 } else if (boundary.pendingTasks === 0) {
542 // This must have been the last segment we were waiting on. This boundary is now complete.
543 // We can now cancel any pending task on the fallback since we won't need to show it anymore.
544 - boundary.fallbackAbortableTask.forEach(abortTaskSoft, request);
545 - boundary.fallbackAbortableTask.clear();
544 + boundary.fallbackAbortableTasks.forEach(abortTaskSoft, request);
545 + boundary.fallbackAbortableTasks.clear();
546 if (segment.parentFlushed) {
547 // Our parent segment already flushed, so we need to schedule this segment to be emitted.
548 boundary.completedSegments.push(segment);
@@ -625,13 +625,13 @@ function performWork(request: Request): void {
625 ReactCurrentDispatcher.current = Dispatcher;
626
627 try {
628 - const pingedTask = request.pingedTask;
628 + const pingedTasks = request.pingedTasks;
629 let i;
630 - for (i = 0; i < pingedTask.length; i++) {
631 - const task = pingedTask[i];
630 + for (i = 0; i < pingedTasks.length; i++) {
631 + const task = pingedTasks[i];
632 retryTask(request, task);
633 }
634 - pingedTask.splice(0, i);
634 + pingedTasks.splice(0, i);
635 if (request.status === FLOWING) {
636 flushCompletedQueues(request);
637 }
@@ -953,14 +953,14 @@ function flushCompletedQueues(request: Request): void {
953 flushBuffered(destination);
954 if (
955 request.allPendingTasks === 0 &&
956 - request.pingedTask.length === 0 &&
956 + request.pingedTasks.length === 0 &&
957 request.clientRenderedBoundaries.length === 0 &&
958 request.completedBoundaries.length === 0
959 // We don't need to check any partially completed segments because
960 // either they have pending task or they're complete.
961 ) {
962 if (__DEV__) {
963 - if (request.abortableTask.size !== 0) {
963 + if (request.abortableTasks.size !== 0) {
964 console.error(
965 'There was still abortable task at the root when we closed. This is a bug in React.',
966 );
@@ -992,9 +992,9 @@ export function startFlowing(request: Request): void {
992 // This is called to early terminate a request. It puts all pending boundaries in client rendered state.
993 export function abort(request: Request): void {
994 try {
995 - const abortableTask = request.abortableTask;
996 - abortableTask.forEach(abortTask, request);
997 - abortableTask.clear();
995 + const abortableTasks = request.abortableTasks;
996 + abortableTasks.forEach(abortTask, request);
997 + abortableTasks.clear();
998 if (request.status === FLOWING) {
999 flushCompletedQueues(request);
1000 }