Skip to content

Rpc.Handler doesn't expose successSchema for runtime schema inspection #6064

@schickling-assistant

Description

@schickling-assistant

Problem

When implementing custom RPC servers (e.g. for Cloudflare Durable Object RPC), we need to access the successSchema property on RPC handlers to:

  1. Check if an RPC uses streaming via RpcSchema.isStreamSchema(rpc.successSchema)
  2. Get stream schemas via RpcSchema.getStreamSchemas(rpc.successSchema.ast)

Currently, successSchema is not part of the public Rpc.Handler type, forcing us to use unsafe type assertions like (rpc as any).successSchema.

Reproduction

import { Rpc, RpcSchema } from 'effect'

// This is what we need to do, but successSchema isn't publicly typed:
const rpc = group.requests.get(request.tag) as Rpc.AnyWithProps
const isStream = RpcSchema.isStreamSchema((rpc as any).successSchema)
const streamSchemas = RpcSchema.getStreamSchemas((rpc as any).successSchema.ast)

Expected behavior

Rpc.AnyWithProps (or a similar public type) should expose successSchema so that custom RPC server implementations can inspect schemas without unsafe casts.

Context

This is needed for implementing custom transport layers (e.g. Cloudflare Durable Object RPC) where the server needs to differentiate between regular and streaming RPCs at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions