Skip to content

Conversation

@denk0403
Copy link
Contributor

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.
image

@denk0403 denk0403 changed the title #33534 Allow returning a temporary reference inside an async function Allow returning a temporary reference inside an async function Jul 11, 2025
@react-sizebot
Copy link

Comparing: fe81314...6ff0af1

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.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 530.70 kB 530.70 kB = 93.70 kB 93.70 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 655.25 kB 655.25 kB = 115.40 kB 115.40 kB
facebook-www/ReactDOM-prod.classic.js = 675.13 kB 675.13 kB = 118.75 kB 118.75 kB
facebook-www/ReactDOM-prod.modern.js = 665.56 kB 665.56 kB = 117.11 kB 117.11 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 6ff0af1

@sebmarkbage sebmarkbage merged commit 1d16396 into facebook:main Aug 2, 2025
242 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 2, 2025
<!--
  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)
ch4og pushed a commit to csmplay/mapban that referenced this pull request Nov 18, 2025
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react) ([source](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react)) | [`19.1.10` -> `19.2.6`](https://renovatebot.com/diffs/npm/@types%2freact/19.1.10/19.2.6) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2freact/19.2.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2freact/19.1.10/19.2.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom) ([source](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom)) | [`19.1.7` -> `19.2.3`](https://renovatebot.com/diffs/npm/@types%2freact-dom/19.1.7/19.2.3) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2freact-dom/19.2.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2freact-dom/19.1.7/19.2.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [react](https://react.dev/) ([source](https://github.com/facebook/react/tree/HEAD/packages/react)) | [`19.1.1` -> `19.2.0`](https://renovatebot.com/diffs/npm/react/19.1.1/19.2.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/react/19.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react/19.1.1/19.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [react-dom](https://react.dev/) ([source](https://github.com/facebook/react/tree/HEAD/packages/react-dom)) | [`19.1.1` -> `19.2.0`](https://renovatebot.com/diffs/npm/react-dom/19.1.1/19.2.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/react-dom/19.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-dom/19.1.1/19.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>facebook/react (react)</summary>

### [`v19.2.0`](https://github.com/facebook/react/blob/HEAD/CHANGELOG.md#1920-October-1st-2025)

[Compare Source](facebook/react@v19.1.1...v19.2.0)

Below is a list of all new features, APIs, and bug fixes.

Read the [React 19.2 release post](https://react.dev/blog/2025/10/01/react-19-2) for more information.

##### New React Features

- [`<Activity>`](https://react.dev/reference/react/Activity): A new API to hide and restore the UI and internal state of its children.
- [`useEffectEvent`](https://react.dev/reference/react/useEffectEvent) is a React Hook that lets you extract non-reactive logic into an [Effect Event](https://react.dev/learn/separating-events-from-effects#declaring-an-effect-event).
- [`cacheSignal`](https://react.dev/reference/react/cacheSignal) (for RSCs) lets your know when the `cache()` lifetime is over.
- [React Performance tracks](https://react.dev/reference/dev-tools/react-performance-tracks) appear on the Performance panel’s timeline in your browser developer tools

##### New React DOM Features

- Added resume APIs for partial pre-rendering with Web Streams:
  - [`resume`](https://react.dev/reference/react-dom/server/resume): to resume a prerender to a stream.
  - [`resumeAndPrerender`](https://react.dev/reference/react-dom/static/resumeAndPrerender): to resume a prerender to HTML.
- Added resume APIs for partial pre-rendering with Node Streams:
  - [`resumeToPipeableStream`](https://react.dev/reference/react-dom/server/resumeToPipeableStream): to resume a prerender to a stream.
  - [`resumeAndPrerenderToNodeStream`](https://react.dev/reference/react-dom/static/resumeAndPrerenderToNodeStream): to resume a prerender to HTML.
- Updated [`prerender`](https://react.dev/reference/react-dom/static/prerender) APIs to return a `postponed` state that can be passed to the `resume` APIs.

##### Notable changes

- React DOM now batches suspense boundary reveals, matching the behavior of client side rendering. This change is especially noticeable when animating the reveal of Suspense boundaries e.g. with the upcoming `<ViewTransition>` Component. React will batch as much reveals as possible before the first paint while trying to hit popular first-contentful paint metrics.
- Add Node Web Streams (`prerender`, `renderToReadableStream`) to server-side-rendering APIs for Node.js
- Use underscore instead of `:` IDs generated by useId

##### All Changes

##### React

- `<Activity />` was developed over many years, starting before `ClassComponent.setState` ([@&#8203;acdlite](https://github.com/acdlite) [@&#8203;sebmarkbage](https://github.com/sebmarkbage) and many others)
- Stringify context as "SomeContext" instead of "SomeContext.Provider" ([@&#8203;kassens](https://github.com/kassens) [#&#8203;33507](facebook/react#33507))
- Include stack of cause of React instrumentation errors with `%o` placeholder ([@&#8203;eps1lon](https://github.com/eps1lon) [#&#8203;34198](facebook/react#34198))
- Fix infinite `useDeferredValue` loop in popstate event ([@&#8203;acdlite](https://github.com/acdlite) [#&#8203;32821](facebook/react#32821))
- Fix a bug when an initial value was passed to `useDeferredValue` ([@&#8203;acdlite](https://github.com/acdlite) [#&#8203;34376](facebook/react#34376))
- Fix a crash when submitting forms with Client Actions ([@&#8203;sebmarkbage](https://github.com/sebmarkbage) [#&#8203;33055](facebook/react#33055))
- Hide/unhide the content of dehydrated suspense boundaries if they resuspend ([@&#8203;sebmarkbage](https://github.com/sebmarkbage) [#&#8203;32900](facebook/react#32900))
- Avoid stack overflow on wide trees during Hot Reload ([@&#8203;sophiebits](https://github.com/sophiebits) [#&#8203;34145](facebook/react#34145))
- Improve Owner and Component stacks in various places ([@&#8203;sebmarkbage](https://github.com/sebmarkbage), [@&#8203;eps1lon](https://github.com/eps1lon): [#&#8203;33629](facebook/react#33629), [#&#8203;33724](facebook/react#33724), [#&#8203;32735](facebook/react#32735), [#&#8203;33723](facebook/react#33723))
- Add `cacheSignal` ([@&#8203;sebmarkbage](https://github.com/sebmarkbage) [#&#8203;33557](facebook/react#33557))

##### React DOM

- Block on Suspensey Fonts during reveal of server-side-rendered content ([@&#8203;sebmarkbage](https://github.com/sebmarkbage) [#&#8203;33342](facebook/react#33342))
- Use underscore instead of `:` for IDs generated by `useId` ([@&#8203;sebmarkbage](https://github.com/sebmarkbage), [@&#8203;eps1lon](https://github.com/eps1lon): [#&#8203;32001](facebook/react#32001), [#&#8203;33342](https://github.com/facebook/react/pull/33342)[#&#8203;33099](https://github.com/facebook/react/pull/33099), [#&#8203;33422](facebook/react#33422))
- Stop warning when ARIA 1.3 attributes are used ([@&#8203;Abdul-Omira](https://github.com/Abdul-Omira) [#&#8203;34264](facebook/react#34264))
- Allow `nonce` to be used on hoistable styles ([@&#8203;Andarist](https://github.com/Andarist) [#&#8203;32461](facebook/react#32461))
- Warn for using a React owned node as a Container if it also has text content ([@&#8203;sebmarkbage](https://github.com/sebmarkbage) [#&#8203;32774](facebook/react#32774))
- s/HTML/text for for error messages if text hydration mismatches ([@&#8203;rickhanlonii](https://github.com/rickhanlonii) [#&#8203;32763](facebook/react#32763))
- Fix a bug with `React.use` inside `React.lazy`-ed Component ([@&#8203;hi-ogawa](https://github.com/hi-ogawa) [#&#8203;33941](facebook/react#33941))
- Enable the `progressiveChunkSize` option for server-side-rendering APIs ([@&#8203;sebmarkbage](https://github.com/sebmarkbage) [#&#8203;33027](facebook/react#33027))
- Fix a bug with deeply nested Suspense inside Suspense fallback when server-side-rendering ([@&#8203;gnoff](https://github.com/gnoff) [#&#8203;33467](facebook/react#33467))
- Avoid hanging when suspending after aborting while rendering ([@&#8203;gnoff](https://github.com/gnoff) [#&#8203;34192](facebook/react#34192))
- Add Node Web Streams to server-side-rendering APIs for Node.js ([@&#8203;sebmarkbage](https://github.com/sebmarkbage) [#&#8203;33475](facebook/react#33475))

##### React Server Components

- Preload `<img>` and `<link>` using hints before they're rendered ([@&#8203;sebmarkbage](https://github.com/sebmarkbage) [#&#8203;34604](facebook/react#34604))
- Log error if production elements are rendered during development ([@&#8203;eps1lon](https://github.com/eps1lon) [#&#8203;34189](facebook/react#34189))
- Fix a bug when returning a Temporary reference (e.g. a Client Reference) from Server Functions ([@&#8203;sebmarkbage](https://github.com/sebmarkbage) [#&#8203;34084](facebook/react#34084), [@&#8203;denk0403](https://github.com/denk0403) [#&#8203;33761](facebook/react#33761))
- Pass line/column to `filterStackFrame` ([@&#8203;eps1lon](https://github.com/eps1lon) [#&#8203;33707](facebook/react#33707))
- Support Async Modules in Turbopack Server References ([@&#8203;lubieowoce](https://github.com/lubieowoce) [#&#8203;34531](facebook/react#34531))
- Add support for .mjs file extension in Webpack ([@&#8203;jennyscript](https://github.com/jennyscript) [#&#8203;33028](facebook/react#33028))
- Fix a wrong missing key warning ([@&#8203;unstubbable](https://github.com/unstubbable) [#&#8203;34350](facebook/react#34350))
- Make console log resolve in predictable order ([@&#8203;sebmarkbage](https://github.com/sebmarkbage) [#&#8203;33665](facebook/react#33665))

##### React Reconciler

- [createContainer](https://github.com/facebook/react/blob/v19.2.0/packages/react-reconciler/src/ReactFiberReconciler.js#L255-L261) and [createHydrationContainer](https://github.com/facebook/react/blob/v19.2.0/packages/react-reconciler/src/ReactFiberReconciler.js#L305-L312) had their parameter order adjusted after `on*` handlers to account for upcoming experimental APIs

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNDguNCIsInVwZGF0ZWRJblZlciI6IjQyLjEwLjUiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->

Reviewed-on: https://git.in.csmpro.ru/csmpro/csm-mapban/pulls/36
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
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.

Bug: Server functions error when returning a client reference

4 participants