-
-
Notifications
You must be signed in to change notification settings - Fork 522
Open
Description
Problem
When implementing custom RPC servers (e.g. for Cloudflare Durable Object RPC), we need to access the successSchema property on RPC handlers to:
- Check if an RPC uses streaming via
RpcSchema.isStreamSchema(rpc.successSchema) - 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels