Repository: facebook/react
File: packages/react-reconciler/src/ReactFiberWorkLoop.js (JavaScript)

Code before:
          case SuspendedOnImmediate:
          case SuspendedOnData: {
            if (!didSuspendInShell) {
              const handler = getSuspenseHandler();
              if (handler === null) {
                didSuspendInShell = true;
                const counter = ++root.shellSuspendCounter;
                if (counter > 100) {
                  // This root has suspended repeatedly in the shell without
                  // making any progress (i.e. committing something). This is
                  // highly suggestive of an infinite ping loop, often caused by
                  // an accidental Async Client Component.
                  //
                  // During a transition, we can suspend the work loop until the
                  // promise to resolve, but this is a sync render, so that's
                  // not an option. We also can't show a fallback, because none
                  // was provided. So our last resort is to throw an error.
                  //
                  // TODO: Remove this error in a future release. Other ways
                  // of handling this case include forcing a concurrent render,
                  // or putting the whole root into offscreen mode.
                  const asyncClientComponentError = new Error(
                    'async/await is not yet supported in Client Components, ' +
                      'only Server Components. This error is often caused by ' +
                      "accidentally adding `'use client'` to a module that " +
                      'was originally written for the server.',
                  );
                  workInProgressSuspendedReason = NotSuspended;
                  workInProgressThrownValue = null;
                  throwAndUnwindWorkLoop(unitOfWork, asyncClientComponentError);
                  break;
                }
              }
            }
            // Intentional fallthrough
          }
          default: {
            // Unwind then continue with the normal work loop.
            workInProgressSuspendedReason = NotSuspended;
            workInProgressThrownValue = null;
            throwAndUnwindWorkLoop(unitOfWork, thrownValue);
            break;
          }
        }
      }
      workLoopSync();
      break;
    } catch (thrownValue) {
      handleThrow(root, thrownValue);
    }
  } while (true);

Review comment (suggestion):
```suggestion
                    'Detected an infinite suspense loop while, ' +
                      'rendering the app shell. This error is often caused by ' +
                      "accidentally adding `'use client'` to a module that " +
                      'was originally written for the server.',
```

Code after:
          case SuspendedOnImmediate:
          case SuspendedOnData: {
            if (!didSuspendInShell && getSuspenseHandler() === null) {
              didSuspendInShell = true;
            }
            // Intentional fallthrough
          }
          default: {
            // Unwind then continue with the normal work loop.
            workInProgressSuspendedReason = NotSuspended;
            workInProgressThrownValue = null;
            throwAndUnwindWorkLoop(unitOfWork, thrownValue);
            break;
          }
        }
      }
      workLoopSync();
      break;
    } catch (thrownValue) {
      handleThrow(root, thrownValue);
    }
  } while (true);

  // Check if something suspended in the shell. We use this to detect an
  // infinite ping loop caused by an uncached promise.
  //
  // Only increment this counter once per synchronous render attempt across the
  // whole tree. Even if there are many sibling components that suspend, this
  // counter only gets incremented once.
  if (didSuspendInShell) {
    root.shellSuspendCounter++;
  }

  resetContextDependencies();

  executionContext = prevExecutionContext;
  popDispatcher(prevDispatcher);
  popCacheDispatcher(prevCacheDispatcher);

  if (workInProgress !== null) {
    // This is a sync render, so we should have finished the whole tree.
    throw new Error(
      'Cannot commit an incomplete root. This error is likely caused by a ' +
        'bug in React. Please file an issue.',
    );
  }

  if (__DEV__) {
    if (enableDebugTracing) {
      logRenderStopped();
    }