Skip to content

Comments

Fix stale executionContext after breakpoint/alert interruption (#17355)#35865

Open
gpardhivvarma wants to merge 1 commit intofacebook:mainfrom
gpardhivvarma:fix/stale-execution-context-17355
Open

Fix stale executionContext after breakpoint/alert interruption (#17355)#35865
gpardhivvarma wants to merge 1 commit intofacebook:mainfrom
gpardhivvarma:fix/stale-execution-context-17355

Conversation

@gpardhivvarma
Copy link

Summary

Fixes #17355.

When execution is interrupted by a breakpoint, alert(), or a browser debugging pause (particularly in Firefox), the finally blocks that normally reset executionContext may not run. This leaves RenderContext or CommitContext flags set even though workInProgress and workInProgressRoot are both null.

On resume, performWorkOnRoot and completeRoot see the stale flags and throw "Should not already be working."

This adds fixStaleExecutionContext() which detects this mismatch — render/commit flags are set but nothing is actually in progress — and clears just those flags before the assertion. It's called at the top of performWorkOnRoot and after flushPendingEffects in completeRoot, the two places that guard with this check.

The fix is defensive: it only activates when the context is genuinely stale, so normal execution paths are unaffected.

How did you test this change?

  • yarn prettier — no formatting issues
  • yarn linc — lint passes on changed files
  • yarn flow dom-browser — no type errors
  • yarn test packages/react-reconciler/src/__tests__/ — all 76 suites pass (1132 tests)

This edge case is inherently difficult to unit-test because it requires simulating an external interruption (breakpoint/alert) mid-render. The fix only runs when executionContext is clearly inconsistent with the actual work-in-progress state, and the existing test suite confirms it doesn't change behavior under normal conditions.

…ook#17355)

When execution is interrupted by a breakpoint, alert(), or browser
debugging pause (particularly in Firefox), the finally blocks that
normally reset executionContext may not run. This leaves RenderContext
or CommitContext flags set even though workInProgress and
workInProgressRoot are both null.

On resume, performWorkOnRoot and completeRoot see the stale flags and
throw "Should not already be working."

Add fixStaleExecutionContext() which detects this mismatch and clears
the stale render/commit flags before the assertion. Called at the top
of performWorkOnRoot and after flushPendingEffects in completeRoot.
@meta-cla meta-cla bot added the CLA Signed label Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Should not already be working" in Firefox after a breakpoint/alert

1 participant