Skip to content

fix(rpc): pass SchemaError failures through request contracts - #918

Closed
omegent-app[bot] wants to merge 1 commit into
mainfrom
fix/schema-error-rpc
Closed

omegent-app[bot] wants to merge 1 commit into
mainfrom
fix/schema-error-rpc

Conversation

@omegent-app

@omegent-app omegent-app Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Why

Typed SchemaError failures did not survive application RPCs: query failures
were promoted to defects by logger middleware, and command/stream failure
wrappers could not encode them against their declared error schemas. Clients
therefore saw a defect or a response decoding error rather than the original
schema failure.

What

Include SchemaError in every makeRpcClient request's common error contract
and let logger middleware preserve typed failures. No application-specific
error type or handler wrapper is needed. Explicitly raised defects remain defects.

How

SchemaErrorCodec encodes the native error as its tag and formatted message,
then decodes through a Schema transformation into an actual SchemaError.
isSchemaError, instanceof, message and toString work on the client.
The decoded issue is a normalized InvalidValue carrying that message; the
original schema AST and input are not transported. Add the codec to the inner
request error union so command metadata and stream failure wrappers encode it
correctly. Authentication middleware errors continue to use middleware schemas.

Validation

Focused tests: codec JSON round-trip and strict wire validation, request error
typing, and real HTTP query/command/stream failure round-trips, including a
failure after the first stream value. An explicit schema defect remains a defect.
All 30 focused tests passed (two pre-existing skipped cases). The full library
push gate passed typechecks, lint and the unit suite. Changesets cover
effect-app and @effect-app/infra.

This supersedes the withdrawn Scanner-specific workaround in
https://github.com/macs-holding/scanner/pull/2445. Scanner will need the published
library release on both API and frontend to receive this transport fix.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@omegent-app
omegent-app Bot marked this pull request as ready for review October 12, 2026 15:36
@pkg-pr-new

pkg-pr-new Bot commented Oct 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

@effect-app/cli

npm i https://pkg.pr.new/@effect-app/cli@918

effect-app

npm i https://pkg.pr.new/effect-app@918

@effect-app/eslint-codegen-model

npm i https://pkg.pr.new/@effect-app/eslint-codegen-model@918

@effect-app/eslint-shared-config

npm i https://pkg.pr.new/@effect-app/eslint-shared-config@918

@effect-app/infra

npm i https://pkg.pr.new/@effect-app/infra@918

@effect-app/vue

npm i https://pkg.pr.new/@effect-app/vue@918

@effect-app/vue-components

npm i https://pkg.pr.new/@effect-app/vue-components@918

commit: 8fca97f

@omegent-app omegent-app Bot closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants