Uh oh!
There was an error while loading. Please reload this page.
feat(rpc): add defect schema option to Rpc.make - #6065
Conversation
Signed-off-by: Marc MacLeod <marbemac+gh@gmail.com>
🦋 Changeset detectedLatest commit: 3db0875 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| readonly payloadSchema: Payload | ||
| readonly successSchema: Success | ||
| readonly errorSchema: Error | ||
| readonly defectSchema: Schema.Schema.Any |
There was a problem hiding this comment.
The schema will have to have no requirements as well
Uh oh!
There was an error while loading. Please reload this page.
Signed-off-by: Marc MacLeod <marbemac+gh@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Tim <hello@timsmart.co>
There were a few other places that need the encoded type updated to any. Also, does the client need updating? Or does it only use the exitSchema api. |
Signed-off-by: Marc MacLeod <marbemac+gh@gmail.com>
marbemac
commented
Feb 15, 2026
Ah yeah missed those - updated. Regarding the the client, I don't think so? It only uses Rpc.exitSchema(). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Type
Description
Right now
@effect/rpchardcodesSchema.Defectfor serializing defects across RPC boundaries. This is fine for external APIs, but for internal service boundaries it strips stack traces and other diagnostic info which makes debugging painful.This PR adds an optional
defectparameter toRpc.makethat lets you override the defect schema per-RPC. It defaults toSchema.Defectso nothing changes for existing code.The custom schema flows through
Rpc.exitSchema()and the server-side encoding inRpcServer. Protocol-level defects (fatal server crashes outside any specific RPC context) still useSchema.Defect— those represent infrastructure failures, not application errors.Changes
Rpc.ts: AddeddefectSchemafield toRpcandAnyWithPropsinterfaces, threaded throughmakeProtoand all Proto methods, addeddefectoption toRpc.make, updatedexitSchemato userpc.defectSchemaRpcServer.ts: Added pre-computedencodeDefecttoSchemascache, threaded throughhandleEncodeandsendRequestDefectexitSchemaround-trip with custom defect schema, plus full e2e test over HTTP with NDJSON serialization