From 39db6d8235655248949e7029f57b7d66e27e8ee5 Mon Sep 17 00:00:00 2001 From: elpresidank Date: Tue, 2 Jun 2026 08:41:36 -0500 Subject: [PATCH] Use tagged errors for dispatch RPC --- ts/EFFECT_NATIVE_REWRITE_AUDIT.md | 23 ++++++++++++++++++++ ts/packages/client/src/rpc/contract.ts | 3 +-- ts/packages/flow/src/gateway/rpc-contract.ts | 3 +-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ts/EFFECT_NATIVE_REWRITE_AUDIT.md b/ts/EFFECT_NATIVE_REWRITE_AUDIT.md index 5f6cb694..9b03ed5f 100644 --- a/ts/EFFECT_NATIVE_REWRITE_AUDIT.md +++ b/ts/EFFECT_NATIVE_REWRITE_AUDIT.md @@ -1429,6 +1429,27 @@ Notes: - `cd ts && bun run lint` - `git diff --check` +### 2026-06-02: RPC Dispatch Tagged Error Slice + +- Status: migrated and package-verified. +- Completed: + - Replaced the remaining production `S.ErrorClass` usage in the Flow gateway + RPC contract with `S.TaggedErrorClass`. + - Normalized the client-side RPC `DispatchError` counterpart to the same + tagged-error schema shape so both wire contract copies stay aligned. + - Closed the scratch-note `S.ErrorClass` finding for production code. The + remaining plain `new Error` matches are test-only helpers or external + host-boundary simulations. +- Verification: + - `cd ts && bun run check:tsgo` + - `cd ts/packages/flow && bunx --bun vitest run src/__tests__/gateway-dispatcher.test.ts` + - `cd ts/packages/client && bunx --bun vitest run src/__tests__/rpc-timeout.test.ts` + - `cd ts && bun run check` + - `cd ts && bun run build` + - `cd ts && bun run test` + - `cd ts && bun run lint` + - `git diff --check` + ## Subagent Findings To Preserve - MCP/workbench: @@ -1485,6 +1506,8 @@ Notes: Socket errors/JSON parsing now use tagged errors and Schema decoding. The remaining client `newableFactory` assertions are documented as public API compatibility boundaries for this loop. + - Gateway/client `DispatchError` contracts now use `S.TaggedErrorClass`; do + not reopen `S.ErrorClass` unless a new production match appears. - Gateway `DispatchStream` now uses Effect-native dispatcher streaming callbacks instead of nested `Effect.runPromiseWith`, and client streaming facade callbacks now decode the legacy envelope through Schema before diff --git a/ts/packages/client/src/rpc/contract.ts b/ts/packages/client/src/rpc/contract.ts index c6c9da92..09a615d8 100644 --- a/ts/packages/client/src/rpc/contract.ts +++ b/ts/packages/client/src/rpc/contract.ts @@ -14,8 +14,7 @@ export class DispatchStreamChunk extends S.Class("DispatchS complete: S.Boolean, }) {} -export class DispatchError extends S.ErrorClass("DispatchError")({ - _tag: S.tag("DispatchError"), +export class DispatchError extends S.TaggedErrorClass()("DispatchError", { message: S.String, }) {} diff --git a/ts/packages/flow/src/gateway/rpc-contract.ts b/ts/packages/flow/src/gateway/rpc-contract.ts index c6c9da92..09a615d8 100644 --- a/ts/packages/flow/src/gateway/rpc-contract.ts +++ b/ts/packages/flow/src/gateway/rpc-contract.ts @@ -14,8 +14,7 @@ export class DispatchStreamChunk extends S.Class("DispatchS complete: S.Boolean, }) {} -export class DispatchError extends S.ErrorClass("DispatchError")({ - _tag: S.tag("DispatchError"), +export class DispatchError extends S.TaggedErrorClass()("DispatchError", { message: S.String, }) {}