Skip to content
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

[compiler][fixtures] Patch error-handling edge case in snap evaluator #31082

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

[ghstack-poisoned]
Copy link

vercel bot commented Sep 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 30, 2024 4:43pm

@@ -75,7 +75,7 @@ export const FIXTURE_ENTRYPOINT = {

### Eval output
(kind: ok) [[ (exception in render) Error: throw with error! ]]
[[ (exception in render) Error: throw with error! ]]
[2]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that we now correctly do the non-throwing re-render instead of returning a cached error

[ghstack-poisoned]
Copy link
Contributor

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

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

accepting to unblock but one question

if (this.state.hasError) {
this.setState({hasError: false, error: null});
if (this.state.errorFromLastRender !== NO_ERROR_SENTINEL) {
// Reschedule a third render that immediately returns the cached error
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't get the comment here, seems backwards since we're clearing errorFromLastRender? wouldn't this not immediately return the error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wouldn't return errorFromLastRender, but it would find the correct one in this.propsErrorMap.
I had trouble figuring out another solution to render components exactly once (per entry in sequentialRenders) and clear the error-state to retry rendering when props change

Definitely not sold that this is the best way writing this and I'm probably missing a common pattern, any suggestions welcome.

[ghstack-poisoned]
@mofeiZ mofeiZ merged commit 02a0ef4 into gh/mofeiZ/24/base Sep 30, 2024
19 of 20 checks passed
mofeiZ added a commit that referenced this pull request Sep 30, 2024
Fix edge case in which we incorrectly returned a cached exception instead of trying to rerender with new props.
ghstack-source-id: 843fb85df4a2ae7a88f296104fb16b5f9a34c76e
Pull Request resolved: #31082
@mofeiZ mofeiZ deleted the gh/mofeiZ/24/head branch September 30, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants