Skip to content

docs(rpc): document the promise chain inference limitation - #897

Merged
yusukebe merged 2 commits into
honojs:mainfrom
yigiterturk-dev:docs/rpc-promise-chain-limitation
Aug 22, 2026
Merged

docs(rpc): document the promise chain inference limitation#897
yusukebe merged 2 commits into
honojs:mainfrom
yigiterturk-dev:docs/rpc-promise-chain-limitation

Conversation

@yigiterturk-dev

Copy link
Copy Markdown
Contributor

Documents the RPC limitation reported in honojs/hono#4765, where a handler that
returns a .then() chain directly infers unknown on the client.

@yusukebe suggested
leaving the behaviour as-is and documenting the limitation, so this adds it
under "Known issues" in the RPC guide, with the reason it happens and the two
ways around it.

Each snippet was checked against hono main:

  • the .then() chain infers unknown
  • awaiting the promise and returning c.json(d) infers { hello: string }
  • annotating then<TypedResponse<{ hello: string }, 200, 'json'>> infers { hello: string }

TypedResponse is used for the annotation because JSONRespondReturn is not
exported from the package.

A handler that returns a `.then()` chain directly infers `unknown` on the
client. Inside the callback, the type of `c` depends on the handler's return
type, which is what the callback is being used to infer, so TypeScript falls
back to the constraint of the return type and the response type is lost.

Document the limitation under "Known issues" together with the two ways around
it, as suggested in honojs/hono#4765.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019bYuvGzZDDeCezDyTF1T5n
@yusukebe
yusukebe merged commit f4e7385 into honojs:main Aug 22, 2026
2 checks passed
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.

2 participants