-
Notifications
You must be signed in to change notification settings - Fork 49.1k
Description
Returning a temporary client reference from a server function causes an error.
My understanding of the issue is that async
functions will automatically check return values for .then()
methods in order to flatten nested promises. However, client references in server functions guard access to virtually all properties.
This can be easily sidestepped by wrapping the return value in an array or plain object, but it's inconvenient.
React version: 19.1.0
Steps To Reproduce
- Create a server function which would return a client reference.
- Call the server function from the client with a client reference (non-RSC-serializable value).
Link to code example:
https://codesandbox.io/p/devbox/server-function-cant-return-client-reference-477k4c
The current behavior
The server function errors before returning a client reference.
The expected behavior
The server function should return the same client reference without error. Client references should not guard accessing the then
property, and should instead return undefined
.