Skip to content

oRPC v2 router: traverseContractProcedures is not a function #238

Backlog

Description

@timschoch

oRPC v2 router: traverseContractProcedures is not a function

Versions: trpc-cli 0.17.1, @orpc/server 2.0.0-beta.53, zod 4.6.7, Node 26.13.1.

Input:

import { os } from '@orpc/server'
import { createCli } from 'trpc-cli'
import { z } from 'zod'

const createPost = os
  .input(z.object({ title: z.string().min(1), tags: z.array(z.string()) }))
  .handler(({ input }) => input)

await createCli({ router: { createPost } }).run()

Expected: a create-post command with --title and --tags, as with @orpc/server 1.16.6. We ran the same code on 1.16.6 and it works.

Actual:

TypeError: traverseContractProcedures is not a function
    at parseOrpcRouter (trpc-cli/dist/parse-router.js:130:24)

What we found in oRPC v2:

  • @orpc/server no longer exports traverseContractProcedures or isProcedure. walkProcedureContractsSync is in the export list, and it looks like the closest match.
  • The procedure definition has inputSchemas?: AnySchema[] in place of inputSchema, so contract['~orpc'].inputSchema is undefined.
  • createCli({ router }) also fails the type check: the v2 router does not match the router type in TrpcCliParams, so TypeScript falls through to the TrpcCliModuleParams overload.
  • The peer range is @orpc/server: ^1.0.0, so pnpm reports an unmet peer.

We know v2 is still a beta. We think a v2 code path in parseOrpcRouter would fix it: walk the procedures with walkProcedureContractsSync and read inputSchemas[0]. We have not tested this.

Workaround we use for now: re-wrap each procedure as a norpc procedure. It works for a flat router. It is a sketch, not a patch:

import { call } from '@orpc/server'
import { createCli, os as cli } from 'trpc-cli'

const cliRouter = Object.fromEntries(
  Object.entries(router).map(([name, procedure]) => [
    name,
    cli.input(procedure['~orpc'].inputSchemas![0]!).handler(({ input }) => call(procedure, input as never)),
  ]),
)

await createCli({ router: cliRouter }).run()

Activity

  1. pullfrog commented on Nov 25, 2026

    @pullfrog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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