Skip to content

Fix 'Should not already be working' error in Firefox after breakpoint… #33420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,19 @@ export function performWorkOnRoot(
forceSync: boolean,
): void {
if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
throw new Error('Should not already be working.');
// When debugging with breakpoints or alerts in older browsers like Chrome 68 on Windows 7,
// the execution context might not get properly reset when execution resumes.
// Instead of throwing an error, we'll reset the execution context and log a warning.
if (__DEV__) {
console.warn(
'React detected an inconsistent state likely caused by debugging interruption. ' +
'Resetting execution context to prevent "Should not already be working" error.'
);
// Reset execution context to prevent the error
executionContext = NoContext;
} else {
throw new Error('Should not already be working.');
}
}

if (enableProfilerTimer && enableComponentPerformanceTrack) {
Expand Down Expand Up @@ -3244,7 +3256,19 @@ function commitRoot(
flushRenderPhaseStrictModeWarningsInDEV();

if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
throw new Error('Should not already be working.');
// When debugging with breakpoints or alerts in older browsers like Chrome 68 on Windows 7,
// the execution context might not get properly reset when execution resumes.
// Instead of throwing an error, we'll reset the execution context and log a warning.
if (__DEV__) {
console.warn(
'React detected an inconsistent state likely caused by debugging interruption. ' +
'Resetting execution context to prevent "Should not already be working" error.'
);
// Reset execution context to prevent the error
executionContext = NoContext;
} else {
throw new Error('Should not already be working.');
}
}

if (enableProfilerTimer && enableComponentPerformanceTrack) {
Expand Down