Skip to content

Commit be3bec7

Browse files
committed
Don't yield before commit during sync error retry
1 parent e0a8526 commit be3bec7

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

packages/react-reconciler/src/ReactFiberScheduler.new.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,11 @@ function renderRoot(
854854
// caused by tearing due to a mutation during an event. Try rendering
855855
// one more time without yiedling to events.
856856
prepareFreshStack(root, expirationTime);
857-
// Return a continutation to maintian the same priority, but pass
858-
// isSync true to disable yielding.
859-
return renderRoot.bind(null, root, expirationTime, true);
857+
scheduleCallback(
858+
ImmediatePriority,
859+
renderRoot.bind(null, root, expirationTime),
860+
);
861+
return null;
860862
}
861863
// If we're already rendering synchronously, commit the root in its
862864
// errored state.

packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ describe('ReactIncrementalErrorHandling', () => {
134134
'ErrorMessage',
135135
]);
136136

137-
if (enableNewScheduler) {
138-
expect(ReactNoop.getChildren()).toEqual([]);
139-
Scheduler.flushAll();
140-
}
141-
142137
expect(ReactNoop.getChildren()).toEqual([span('Caught an error: oops!')]);
143138
});
144139

@@ -342,23 +337,14 @@ describe('ReactIncrementalErrorHandling', () => {
342337
// Finish the rest of the async work
343338
expect(Scheduler).toFlushAndYieldThrough(['Sibling']);
344339

345-
// React retries once, synchronously, before throwing.
346-
if (enableNewScheduler) {
347-
// New scheduler yields in between render and commit
348-
Scheduler.unstable_flushNumberOfYields(1);
349-
expect(Scheduler).toHaveYielded(['Parent', 'BadRender', 'Sibling']);
350-
// Error is thrown during commit
351-
expect(() => Scheduler.flushAll()).toThrow('oops');
352-
} else {
353-
// Old scheduler renders, commits, and throws synchronously
354-
expect(() => Scheduler.unstable_flushNumberOfYields(1)).toThrow('oops');
355-
expect(Scheduler).toHaveYielded([
356-
'Parent',
357-
'BadRender',
358-
'Sibling',
359-
'commit',
360-
]);
361-
}
340+
// Old scheduler renders, commits, and throws synchronously
341+
expect(() => Scheduler.unstable_flushNumberOfYields(1)).toThrow('oops');
342+
expect(Scheduler).toHaveYielded([
343+
'Parent',
344+
'BadRender',
345+
'Sibling',
346+
'commit',
347+
]);
362348
expect(ReactNoop.getChildren()).toEqual([]);
363349
});
364350

0 commit comments

Comments
 (0)