facebook/react · error · Error

349

349

Error message

Expected a work-in-progress root. This is a bug in React. Please file an issue.

What it means

updateClassComponent() implements the React DevTools 'force the selected component to error' feature. In DEV builds, shouldError() returns true for a class component DevTools marked to fail; React fabricates a 'Simulated error coming from DevTools' and queues a class error update so the nearest boundary shows its fallback. Creating that update needs the root currently being rendered (getWorkInProgressRoot()); a null root means the render bookkeeping is broken.

Source

Thrown at packages/react-reconciler/src/ReactFiberBeginWork.js:1643

        const tempInstance = new ctor(
          workInProgress.memoizedProps,
          instance.context,
        );
        const state = tempInstance.state;
        instance.updater.enqueueSetState(instance, state, null);
        break;
      }
      case true: {
        workInProgress.flags |= DidCapture;
        workInProgress.flags |= ShouldCapture;
        // eslint-disable-next-line react-internal/prod-error-codes
        const error = new Error('Simulated error coming from DevTools');
        const lane = pickArbitraryLane(renderLanes);
        workInProgress.lanes = mergeLanes(workInProgress.lanes, lane);
        // Schedule the error boundary to re-render using updated state
        const root: FiberRoot | null = getWorkInProgressRoot();
        if (root === null) {
          throw new Error(
            'Expected a work-in-progress root. This is a bug in React. Please file an issue.',
          );
        }
        const update = createClassErrorUpdate(lane);
        initializeClassErrorUpdate(
          update,
          root,
          workInProgress,
          createCapturedValueAtFiber(error, workInProgress),
        );
        enqueueCapturedUpdate(workInProgress, update);
        break;
      }
    }
  }

  // Push context providers early to prevent context stack mismatches.
  // During mounting we don't know the child context yet as the instance doesn't exist.

View on GitHub (pinned to eafeac097b)

Solutions

  1. Update the React DevTools extension to a version matching your React build
  2. Retry with the DevTools error-simulation toggle off - this path cannot fire without DevTools
  3. Reload the page - a null work-in-progress root is transient DEV state
  4. If it reproduces with DevTools alone, file an issue describing the component tree shape
Defensive patterns

Strategy: validation

Validate before calling

if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined') {
  if (__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers.size === 0) {
    console.warn('React DevTools failed to attach - update the extension to match your React version');
  }
}

Prevention

When it happens

Trigger: DevTools error simulation pressed on a class component while the work-in-progress root is unexpectedly null - an interrupted render, DevTools mutating the tree concurrently, or an internal state bug. DEV builds only; the entire switch is compiled out of production.

Common situations: Debugging with React DevTools open while hot-reloading or inspecting; an older DevTools extension against a newer React canary; StrictMode DEV double-rendering combined with DevTools interactions.

Related errors


AI-assisted analysis of facebook/react@eafeac097b (2026-08-21). Data as JSON: /api/errors/161307f22a352a35. Report an issue: GitHub.