Skip to content

Fix 'Should not already be working' error after debugger pause in Firefox#36256

Open
SAY-5 wants to merge 1 commit intofacebook:mainfrom
SAY-5:fix/firefox-breakpoint-warning
Open

Fix 'Should not already be working' error after debugger pause in Firefox#36256
SAY-5 wants to merge 1 commit intofacebook:mainfrom
SAY-5:fix/firefox-breakpoint-warning

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 12, 2026

This fixes the long-standing issue where React throws "Should not already be working" in Firefox (and sometimes Chrome) when you hit a breakpoint or call alert() during a render.

When a debugger breakpoint or alert() pauses JavaScript mid-render, the browser's event loop can still fire scheduled callbacks. React's scheduler picks up one of those callbacks and tries to start new work, but executionContext still has RenderContext or CommitContext set from the paused render. The guard sees this and throws, even though there's no actual concurrent work — JS is single-threaded, the old work is just frozen.

The fix changes both guard locations (performWorkOnRoot and completeRoot) to reset executionContext instead of throwing. In DEV mode we log a console.error so it's still visible if this ever fires outside of a debugging session, which would point to a real bug worth investigating.

Fixes #17355

When you hit a breakpoint or call alert() in Firefox mid-render, the
browser pauses JS and then fires scheduler callbacks while React's
executionContext still has RenderContext/CommitContext set. This made
performWorkOnRoot throw "Should not already be working" even though
nothing was actually running concurrently.

Instead of throwing, reset executionContext to NoContext and log a
DEV warning. JS is single-threaded — if we're entering these functions
while the context says mid-work, the previous work was frozen by the
browser, not running concurrently.

Fixes facebook#17355
@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Apr 12, 2026

Hi @SAY-5!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link
Copy Markdown

@buugdig buugdig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bb-test-review

Copy link
Copy Markdown

@buugdig buugdig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bb-test-review-probe-delete-me

@meta-cla meta-cla bot added the CLA Signed label Apr 12, 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

2 participants