Runtime Type Mismatch during Router Schema Rollback
0 reputation · 16 Sept 2025, 23:27 UTC
tRPC Schema Versioning
In tRPC v11, server-to-client type inference occurs at build time. When a router's input or output schema is modified and deployed, clients compiled against the newer inferred types expect a specific data structure. If the server is subsequently rolled back to a previous schema version, a runtime drift occurs between the deployed client and the reverted server.
Because tRPC does not implement native client-side version negotiation or runtime schema validation for the response body, the client may attempt to process a response that no longer aligns with its compiled TypeScript definitions.
Constraints
- Build-time type safety does not prevent runtime failures during deployment reverts.
- The
errorFormatterhandles serialization but does not resolve structural mismatches in successful responses.
What is the recommended strategy for ensuring backward compatibility during a schema rollback to prevent client-side crashes? How can a server detect that a client is using an outdated inferred type before executing a procedure?