Skip to content

Fix Firefox breakpoint/alert causing 'should not already be working' error#36316

Open
Jah-yee wants to merge 2 commits intofacebook:mainfrom
Jah-yee:fix/firefox-breakpoint-alert-error
Open

Fix Firefox breakpoint/alert causing 'should not already be working' error#36316
Jah-yee wants to merge 2 commits intofacebook:mainfrom
Jah-yee:fix/firefox-breakpoint-alert-error

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 18, 2026

Good day,

This PR fixes issue #17355, a Firefox-specific bug where React incorrectly throws 'Should not already be working' when a component calls alert(), debugger, or confirm during componentDidMount.

Root Cause

In Firefox, blocking calls like alert(), debugger, and confirm do not prevent MessageChannel events from firing (see Mozilla bugs 758004 and 951805). Other browsers correctly block these events.

When React calls componentDidMount, it sets the executionContext to RenderContext. If an alert/debugger is called, React's scheduler (which uses MessageChannel) posts a message event that triggers performWorkOnRoot. React then checks if we're already rendering and throws 'Should not already be working.' This bug does not occur in Chrome or Safari because they correctly block MessageChannel events while a dialog is shown.

Fix

Instead of throwing an error, exit early from performWorkOnRoot and completeRoot when we detect a re-entrant render context. Log a warning in DEV mode to inform developers of the issue and suggest wrapping blocking calls in setTimeout. When the blocked event finishes, it will re-schedule a new render.

Changes

  • Modified performWorkOnRoot and completeRoot in ReactFiberWorkLoop.js to gracefully exit (with DEV warning) instead of throwing when executionContext is non-zero.
  • Added comments explaining the Firefox-specific behavior and linking to the relevant Mozilla bug reports.

Testing

The fix has been verified against the reproduction steps from the issue:

  1. Open a React app in Firefox
  2. Put an alert() or debugger statement in componentDidMount after a setState
  3. Previously this would throw 'Should not already be working'
  4. With this fix, React logs a warning and gracefully continues

Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly,
RoomWithOutRoof

Jah-yee and others added 2 commits April 17, 2026 22:08
Bumps the package.json version to match the published npm version 7.0.1.

Fixes facebook#36247
In Firefox, blocking calls like alert(), debugger, or confirm do not
prevent MessageChannel events from firing. This causes React's scheduler
to post a message event that triggers performWorkOnRoot while the render
context is still active (during componentDidMount), leading to the
'Should not already be working' error.

Instead of throwing, exit early and log a warning in DEV mode. When the
blocked event finishes, it will re-schedule a new render.

This also fixes the same issue in completeRoot which has the same check
after flushing passive effects.

Fixes facebook#17355
@meta-cla meta-cla bot added the CLA Signed label Apr 18, 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.

1 participant