fix(client): match subclasses in ORPCError cross-context instanceof check - #1762
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/json-schema
@orpc/nest
@orpc/next
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — a targeted fix for the ORPCError cross-context instanceof check so subclass instances from foreign dependency graphs are recognized:
- New
getConstructors()generator in@orpc/sharedthat walks the full prototype chain, yielding each constructor - Updated
Symbol.hasInstanceto iterate the full chain instead of checking only the direct constructor - Clean test coverage — the new cross-context test would fail without the fix (subclass
ExtendedCrossContextORPCErrorwould not match), and thegetConstructorstests cover primitives, built-ins, inheritance chains, null-prototype objects, skipped levels, and laziness
All tests, type checks, and lint pass.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Merging this PR will degrade performance by 12.55%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes |

The cross-context
instanceof ORPCErrorworkaround only checked an instance's direct constructor against the registered constructor set, so instances of classes extending anORPCErrorfrom another dependency graph (e.g. Next.js Optimized SSR contexts) failed the check.Symbol.hasInstancenow walks the instance's whole prototype chain, so such subclass instances are recognized asORPCErrortoo.Fixes
ORPCErrornow passinstanceof ORPCError; previously only direct instances matched.instanceoffallback and the extended-class guard are untouched, and only registeredORPCErrorconstructors can match, so no false positives.Testing
getConstructorshelper in@orpc/sharedis covered for primitives, built-ins, inheritance chains, null-prototype objects, and laziness.instanceof ORPCError, and that they stop matching once deregistered.