Skip to content

Client interceptor usage #652

Closed Answered by dosubot bot
rhinodavid asked this question in Q&A
Jun 15, 2025 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

You ran into a subtle but important behavior with orpc's onStart helper. The onStart function is designed to run your callback and then always call next() itself—so if your callback also calls next(), you end up triggering the next handler twice, which results in two requests to the server per call. This is why your first example caused double requests: your callback called next(), and then onStart called it again after your callback finished.

The intended use for onStart is to perform side effects (like starting a timer or logging), but not to call or await next() inside your callback. If you need to wrap the request and measure duration, writing your own interceptor (as in your second …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by rhinodavid
Comment options

You must be logged in to vote
1 reply
@dosubot
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant