Skip to content

Bug: Server functions error when returning a client reference #33534

@denk0403

Description

@denk0403

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.

Image

React version: 19.1.0

Steps To Reproduce

  1. Create a server function which would return a client reference.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions