Skip to main content

Interface: RpcClientProxy

Defined in: rpc/src/types.ts:256

Lifecycle methods added to the RPC client proxy by createRpcClient().

These methods are mixed into the returned proxy object alongside the Durable Object's own methods to provide connection management and debugging.

Properties​

transportInstance​

transportInstance: RpcTransport

Defined in: rpc/src/types.ts:284

Access to the underlying transport instance. Useful for advanced scenarios like checking connection status.

Example​

const client = createRpcClient<MyDO>({
transport: createWebSocketTransport('MY_DO', 'instance-name')
});
const isConnected = client.transportInstance.isConnected?.() ?? false;

Methods​

__asObject()?​

optional __asObject(): Promise<any>

Defined in: rpc/src/types.ts:308

Returns a plain object representation of the proxied object with functions represented as readable strings like "functionName [Function]". Useful for debugging and testing.

Returns​

Promise<any>

Example​

const client = createRpcClient<MyDO>({
transport: createWebSocketTransport('MY_DO', 'instance-name')
});
const structure = await client.__asObject();
// {
// increment: "increment [Function]",
// ctx: {
// storage: {
// get: "get [Function]",
// ...
// }
// }
// }

[dispose]()​

[dispose](): void

Defined in: rpc/src/types.ts:270

Automatic cleanup when using 'using' syntax. Disconnects WebSocket synchronously (ws.close() is synchronous).

Returns​

void

Example​

using client = createRpcClient<MyDO>({
transport: createWebSocketTransport('MY_DO', 'instance-name')
});
// Use client here - auto-connects on first method call
// disconnect() called automatically at end of scope