Commit a6b6ccf
committed
Allow returning a temporary reference inside an async function (#33761)
<!--
Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please
provide enough information so that others can review your pull request.
The three fields below are mandatory.
Before submitting a pull request, please make sure the following is
done:
1. Fork [the repository](https://github.com/facebook/react) and create
your branch from `main`.
2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
TestName` is helpful in development.
5. Run `yarn test --prod` to test in the production environment. It
supports the same options as `yarn test`.
6. If you need a debugger, run `yarn test --debug --watch TestName`,
open `chrome://inspect`, and press "Inspect".
7. Format your code with
[prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
check changed files.
9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
10. If you haven't already, complete the CLA.
Learn more about contributing:
https://reactjs.org/docs/how-to-contribute.html
-->
## Summary
Fixes `await`-ing and returning temporary references in `async`
functions. These two operations invoke `.then()` under the hood if it is
available, which currently results in an "Cannot access then on the
server. You cannot dot into a temporary client reference..." error. This
can easily be reproduced by returning a temporary reference from a
server function.
Fixes #33534
## How did you test this change?
I added a test in a new test file. I wasn't sure where else to put it.
<img width="771" height="138" alt="image"
src="https://github.com/user-attachments/assets/09ffe6eb-271a-4842-a9fe-c68e17b3fb41"
/>
<!--
Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes the user
interface.
How exactly did you verify that your PR solves the issue you wanted to
solve?
If you leave this empty, your PR will very likely be closed.
-->
DiffTrain build for [1d16396](1d16396)1 parent 789bae0 commit a6b6ccf
File tree
26 files changed
+121
-101
lines changed- compiled-rn
- facebook-fbsource/xplat/js
- RKJSModules/vendor/react
- react-dom/cjs
- react-test-renderer/cjs
- react/cjs
- react-native-github/Libraries/Renderer
- implementations
- tools/eslint-plugin-react-hooks
- cjs
26 files changed
+121
-101
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
408 | 408 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
29025 | 29025 | | |
29026 | 29026 | | |
29027 | 29027 | | |
29028 | | - | |
| 29028 | + | |
29029 | 29029 | | |
29030 | 29030 | | |
29031 | 29031 | | |
29032 | | - | |
| 29032 | + | |
29033 | 29033 | | |
29034 | 29034 | | |
29035 | 29035 | | |
| |||
29066 | 29066 | | |
29067 | 29067 | | |
29068 | 29068 | | |
29069 | | - | |
| 29069 | + | |
29070 | 29070 | | |
29071 | 29071 | | |
29072 | | - | |
| 29072 | + | |
29073 | 29073 | | |
29074 | 29074 | | |
29075 | 29075 | | |
| |||
29207 | 29207 | | |
29208 | 29208 | | |
29209 | 29209 | | |
29210 | | - | |
| 29210 | + | |
29211 | 29211 | | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
17128 | 17128 | | |
17129 | 17129 | | |
17130 | 17130 | | |
17131 | | - | |
| 17131 | + | |
17132 | 17132 | | |
17133 | 17133 | | |
17134 | 17134 | | |
17135 | 17135 | | |
17136 | 17136 | | |
17137 | 17137 | | |
17138 | | - | |
| 17138 | + | |
17139 | 17139 | | |
17140 | 17140 | | |
17141 | 17141 | | |
| |||
17157 | 17157 | | |
17158 | 17158 | | |
17159 | 17159 | | |
17160 | | - | |
| 17160 | + | |
17161 | 17161 | | |
17162 | 17162 | | |
17163 | | - | |
| 17163 | + | |
17164 | 17164 | | |
17165 | 17165 | | |
17166 | 17166 | | |
| |||
17258 | 17258 | | |
17259 | 17259 | | |
17260 | 17260 | | |
17261 | | - | |
| 17261 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
19086 | 19086 | | |
19087 | 19087 | | |
19088 | 19088 | | |
19089 | | - | |
| 19089 | + | |
19090 | 19090 | | |
19091 | 19091 | | |
19092 | 19092 | | |
19093 | 19093 | | |
19094 | 19094 | | |
19095 | 19095 | | |
19096 | | - | |
| 19096 | + | |
19097 | 19097 | | |
19098 | 19098 | | |
19099 | 19099 | | |
| |||
19115 | 19115 | | |
19116 | 19116 | | |
19117 | 19117 | | |
19118 | | - | |
| 19118 | + | |
19119 | 19119 | | |
19120 | 19120 | | |
19121 | | - | |
| 19121 | + | |
19122 | 19122 | | |
19123 | 19123 | | |
19124 | 19124 | | |
| |||
19231 | 19231 | | |
19232 | 19232 | | |
19233 | 19233 | | |
19234 | | - | |
| 19234 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
29081 | 29081 | | |
29082 | 29082 | | |
29083 | 29083 | | |
29084 | | - | |
| 29084 | + | |
29085 | 29085 | | |
29086 | 29086 | | |
29087 | 29087 | | |
29088 | | - | |
| 29088 | + | |
29089 | 29089 | | |
29090 | 29090 | | |
29091 | 29091 | | |
| |||
29122 | 29122 | | |
29123 | 29123 | | |
29124 | 29124 | | |
29125 | | - | |
| 29125 | + | |
29126 | 29126 | | |
29127 | 29127 | | |
29128 | | - | |
| 29128 | + | |
29129 | 29129 | | |
29130 | 29130 | | |
29131 | 29131 | | |
| |||
29579 | 29579 | | |
29580 | 29580 | | |
29581 | 29581 | | |
29582 | | - | |
| 29582 | + | |
29583 | 29583 | | |
29584 | 29584 | | |
29585 | 29585 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
17139 | 17139 | | |
17140 | 17140 | | |
17141 | 17141 | | |
17142 | | - | |
| 17142 | + | |
17143 | 17143 | | |
17144 | 17144 | | |
17145 | 17145 | | |
17146 | 17146 | | |
17147 | 17147 | | |
17148 | 17148 | | |
17149 | | - | |
| 17149 | + | |
17150 | 17150 | | |
17151 | 17151 | | |
17152 | 17152 | | |
| |||
17168 | 17168 | | |
17169 | 17169 | | |
17170 | 17170 | | |
17171 | | - | |
| 17171 | + | |
17172 | 17172 | | |
17173 | 17173 | | |
17174 | | - | |
| 17174 | + | |
17175 | 17175 | | |
17176 | 17176 | | |
17177 | 17177 | | |
| |||
17422 | 17422 | | |
17423 | 17423 | | |
17424 | 17424 | | |
17425 | | - | |
| 17425 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
19101 | 19101 | | |
19102 | 19102 | | |
19103 | 19103 | | |
19104 | | - | |
| 19104 | + | |
19105 | 19105 | | |
19106 | 19106 | | |
19107 | 19107 | | |
19108 | 19108 | | |
19109 | 19109 | | |
19110 | 19110 | | |
19111 | | - | |
| 19111 | + | |
19112 | 19112 | | |
19113 | 19113 | | |
19114 | 19114 | | |
| |||
19130 | 19130 | | |
19131 | 19131 | | |
19132 | 19132 | | |
19133 | | - | |
| 19133 | + | |
19134 | 19134 | | |
19135 | 19135 | | |
19136 | | - | |
| 19136 | + | |
19137 | 19137 | | |
19138 | 19138 | | |
19139 | 19139 | | |
| |||
19399 | 19399 | | |
19400 | 19400 | | |
19401 | 19401 | | |
19402 | | - | |
| 19402 | + | |
19403 | 19403 | | |
19404 | 19404 | | |
19405 | 19405 | | |
| |||
0 commit comments