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

Guard against unmounted components when accessing public instances on Fabric #27687

Merged

Conversation

rubennorte
Copy link
Contributor

Summary

This fixes an error in getPublicInstanceFromInstanceHandle where we throw an error when trying to access the public instance from the fiber of an unmounted component. This shouldn't throw but return null instead.

How did you test this change?

Updated unit tests.
Before:
Screenshot 2023-11-10 at 15 26 14

After:
Screenshot 2023-11-10 at 15 28 37

@rubennorte rubennorte changed the title Guard against reset fibers when accessing public instances Guard against unmounted components when accessing public instances on Fabric Nov 10, 2023
@react-sizebot
Copy link

Comparing: 0e352ea...2a68e01

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 175.90 kB 175.90 kB = 54.75 kB 54.75 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 177.97 kB 177.97 kB = 55.39 kB 55.39 kB
facebook-www/ReactDOM-prod.classic.js = 569.68 kB 569.68 kB = 100.27 kB 100.27 kB
facebook-www/ReactDOM-prod.modern.js = 553.54 kB 553.54 kB = 97.36 kB 97.36 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 2a68e01

@rubennorte rubennorte merged commit 6b3834a into facebook:main Nov 10, 2023
2 checks passed
@rubennorte rubennorte deleted the guard-against-cleaned-up-fibers branch November 10, 2023 15:49
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 13, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 13, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
…k#41451)

Summary:

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455
facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Nov 14, 2023
Summary:
Pull Request resolved: #41451

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455

fbshipit-source-id: 05de682d840eed7f22473800efe5fb910c8f3a0d
kodiakhq bot pushed a commit to vercel/next.js that referenced this pull request Nov 15, 2023
Othinn pushed a commit to Othinn/react-native that referenced this pull request Jan 9, 2024
…k#41451)

Summary:
Pull Request resolved: facebook#41451

After [this change in React](facebook/react#27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455

fbshipit-source-id: 05de682d840eed7f22473800efe5fb910c8f3a0d
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
… Fabric (facebook#27687)

## Summary

This fixes an error in `getPublicInstanceFromInstanceHandle` where we
throw an error when trying to access the public instance from the fiber
of an unmounted component. This shouldn't throw but return `null`
instead.

## How did you test this change?

Updated unit tests.
Before: 
<img width="969" alt="Screenshot 2023-11-10 at 15 26 14"
src="https://github.com/facebook/react/assets/117921/ea161616-2775-4fab-8d74-da4bef48d09a">

After: 
<img width="1148" alt="Screenshot 2023-11-10 at 15 28 37"
src="https://github.com/facebook/react/assets/117921/db18b918-b6b6-4925-9cfc-3b4b2f3ab92d">
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
… Fabric (#27687)

## Summary

This fixes an error in `getPublicInstanceFromInstanceHandle` where we
throw an error when trying to access the public instance from the fiber
of an unmounted component. This shouldn't throw but return `null`
instead.

## How did you test this change?

Updated unit tests.
Before:
<img width="969" alt="Screenshot 2023-11-10 at 15 26 14"
src="https://github.com/facebook/react/assets/117921/ea161616-2775-4fab-8d74-da4bef48d09a">

After:
<img width="1148" alt="Screenshot 2023-11-10 at 15 28 37"
src="https://github.com/facebook/react/assets/117921/db18b918-b6b6-4925-9cfc-3b4b2f3ab92d">

DiffTrain build for commit 6b3834a.
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.

5 participants