[DevTools] Fix a crash when rendering a new class Component when simulating errored state#672
[DevTools] Fix a crash when rendering a new class Component when simulating errored state#672everettbu wants to merge 2 commits into
Conversation
Greptile SummaryThis PR fixes a crash in the React DevTools error-simulation feature ( Root cause: Fix:
The change is minimal, well-targeted, and the added comment improves long-term maintainability of the invariant. Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 443bbe0 |
| const {render} = getVersionedRenderImplementation(); | ||
|
|
||
| // @reactVersion >= 18.0 | ||
| it('resets forced error and fallback states when filters are changed', async () => { |
There was a problem hiding this comment.
Misleading test description
The test description says "resets forced error and fallback states when filters are changed", but the test body never modifies store.componentFilters. It exercises toggling forceError on/off via agent.overrideError. The phrase "when filters are changed" likely was copied from another test suite and left unedited.
| it('resets forced error and fallback states when filters are changed', async () => { | |
| it('resets forced error and fallback states when simulated error is toggled off', async () => { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-devtools-shared/src/__tests__/storeForceError-test.js
Line: 37
Comment:
**Misleading test description**
The test description says *"resets forced error and fallback states when filters are changed"*, but the test body never modifies `store.componentFilters`. It exercises toggling `forceError` on/off via `agent.overrideError`. The phrase "when filters are changed" likely was copied from another test suite and left unedited.
```suggestion
it('resets forced error and fallback states when simulated error is toggled off', async () => {
```
How can I resolve this? If you propose a fix, please make it concise.|
Upstream PR was closed or merged. Code is synced via branch mirror. |
Mirror of facebook/react#35985
Original author: eps1lon
Summary
The Fiber reconciler assumes that only committed Error boundaries could have been placed in
forceErrorForFibers. However, DevTools let any unknown Fiber be considered a boundary for which we previously simulated an error. Not only does that incorrectly trigger updates resetting the state, it also causes a crash if we're rendering a Class Component for the first time as a result of simulating an errored state.Now we stop considering all class Components as previously being an error boundary in fallback state. I left a comment in the Fiber reconciler why it's safe to assume that the instance is non-nullable when we're in the
shouldError(fiber) === falsepath.How did you test this change?