Priority
P1
Problem
The tRPC adapter constructs controllers with new and never establishes Croco request context. Constructor injection, request-scoped providers, BatchLoad isolation, and request telemetry are bypassed.
Evidence
packages/protocols-trpc/src/libs/createTrpcRouter.ts uses new controllerCtor() and imports neither Container nor Context.
Desired outcome
tRPC procedures resolve controllers and dependencies through the same scoped runtime model as other Croco transports.
Implementation path
- Add an injectable controller resolver or use the Container at the request boundary.
- Establish and dispose a request context around each procedure.
- Propagate tRPC trace/request metadata into that context.
Acceptance criteria
- Constructor-injected controllers execute through tRPC.
- Concurrent tRPC calls do not share request-scoped state.
- Request context is cleaned up after success and failure.
Validation
- Add DI and concurrent-scope tRPC integration tests.
- Run
pnpm --filter @croco/protocols-trpc test and pnpm typecheck.
Scope
Does not change Container lifetime semantics outside the adapter.
Priority
P1
Problem
The tRPC adapter constructs controllers with
newand never establishes Croco request context. Constructor injection, request-scoped providers, BatchLoad isolation, and request telemetry are bypassed.Evidence
packages/protocols-trpc/src/libs/createTrpcRouter.tsusesnew controllerCtor()and imports neitherContainernorContext.Desired outcome
tRPC procedures resolve controllers and dependencies through the same scoped runtime model as other Croco transports.
Implementation path
Acceptance criteria
Validation
pnpm --filter @croco/protocols-trpc testandpnpm typecheck.Scope
Does not change Container lifetime semantics outside the adapter.