Skip to content

bug: createHydrationHelpers error when trpc router has no routesΒ #2132

@arian81

Description

@arian81

Provide environment information

  System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M2 Pro
    Memory: 70.66 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.2.0 - /opt/homebrew/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 11.3.0 - /opt/homebrew/bin/npm
    pnpm: 10.7.1 - /opt/homebrew/bin/pnpm
    bun: 1.2.5 - ~/.bun/bin/bun

Describe the bug

If you remove the default trpc post route and create a trpc router with no routers in root.ts get the following error in the server.ts

./src/trpc/server.ts:28:2
Type error: Argument of type 'DecorateRouterRecord<DecorateCreateRouterOptions<{}>>' is not assignable to parameter of type 'TypeError<"Generic parameter missing in `createHydrationHelpers<HERE>`">'.
  Type 'DecorateRouterRecord<DecorateCreateRouterOptions<{}>>' is not assignable to type '"Generic parameter missing in `createHydrationHelpers<HERE>`"'.

  26 |
  27 | export const { trpc: api, HydrateClient } = createHydrationHelpers<AppRouter>(
> 28 |  caller,
     |  ^
  29 |  getQueryClient,
  30 | );
  31 |
Next.js build worker exited with code: 1 and signal: null
error: script "build" exited with code 1

Reproduction repo

https://github.com/arian81/t3-stack-trpc-no-endpoints

To reproduce

try bun run build on the reproduction repo or on a fresh setup of t3 stack set appRouter value inside src/server/api/root.ts to the following and the build the proejct :

export const appRouter = createTRPCRouter({});

Additional information

I'm not sure if no endpoint for trpc is an expected constraint but even if expected there should be some proper form of error or eslint rule to prevent the user from getting the vague error currently thrown.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions