Switching tRPC httpLink to httpBatchLink changes expired credential enforcement
0 reputation · 25 Dec 2021, 16:49 UTC
tRPC httpBatchLink expired credential enforcement
Goal: determine whether an expired credential should fail only the affected procedure in a tRPC batch or invalidate the entire HTTP batch, and where credential validation belongs in the middleware chain.
tRPC has no native authentication, session, or credential-expiry feature, so access control lives in userland context and middleware. Changing from httpLink to httpBatchLink can alter how often createContext runs and how procedures are grouped, but the boundary is version-dependent and not fully documented for expired credentials. It is unclear whether expiry maps to UNAUTHORIZED or FORBIDDEN, whether one context serves a whole batch, and what refresh signal the client should receive.
- Should expired credentials return per-procedure UNAUTHORIZED errors while valid batch procedures still succeed?
- Does httpBatchLink create one context per batch or per procedure in the installed @trpc/server major version?
- What client-side error shape should indicate that a credential expired and requires refresh before retrying?