npm @orpc/zod 2.0.0-beta.52
v2.0.0-beta.52

one hour ago

Tip

v2 is close to stable. Tell us what hurt when migrating and what should change before stable: #2446

Highlights

This beta is mostly fixes: several close security gaps in the NestJS integration, the client cookie jar, GET batching, and static file serving. Two breaking changes affect custom tracing backends and code that relied on wrapped iterators keeping their identity.

// A custom tracing backend now receives the value exactly as it was thrown
const span: TracingSpan = {
  recordException(level, error) {
    // `error` keeps its cause chain, custom properties, and `instanceof ORPCError`
  },
  // ...
}

// Routers accept missing entries again
const router: { ping: typeof ping, debug?: typeof debug } = {
  ping,
  debug: isDev ? debug : undefined,
}
  • Breaking — tracing exceptions: TracingSpan.recordException receives the original thrown value instead of a normalized TracingException, so backends see the cause chain, custom properties, and error identity. toTracingException and TracingException are no longer exported from @orpc/shared. OpenTelemetry · Cloudflare Traces
  • Breaking — iterator and stream identity: iterators and streams that pass through validation, tracing, logging, retry, or the timeout plugin no longer keep custom properties or their original class. Hibernation no longer depends on it: the plugin captures the iterator at the handler, so a plugin or middleware that wraps iterators can't silently break it. With the plugin installed, options.procedure is a copy of the procedure. Hibernation
  • NestJS guards: guards, interceptors, and @SetMetadata placed above a method-replacing decorator such as @Span() or @Transactional() now apply to router-based @Implement routes. Requests that were wrongly allowed now get 403. Docs
  • Client security: a GET batch no longer writes per-request headers such as authorization into the URL, and the cookie jar rejects nameless cookies that pass for __Secure- or __Host- cookies. Batch · Cookies
  • WebSocket reconnect: the attempt counter resets only after a connection receives a message or stays open for 5 seconds, so a server that accepts and closes right away gets the backoff and counts toward maxAttempt. Docs
  • Static files: a file that grows while it is being served can no longer send more bytes than its content-length, which could corrupt the next response on the connection. Docs
  • Optional router entries: null and undefined entries in a router or contract are skipped instead of crashing handlers, generators, implement(), and @Implement() at startup.
  • Compressed requests: a compressed binary body from a plain client now decodes to the same File as the uncompressed one.

   🚨 Breaking Changes

  • Stop preserving iterator and stream identity with override  -  by @dinwwwh in #2496 (33f07)
  • shared, server, opentelemetry, cloudflare: Pass the original error to TracingSpan.recordException  -  by @dinwwwh in #2494 (a7644)

   🐞 Bug Fixes

    View changes on GitHub

Don't miss a new zod release

NewReleases is sending notifications on new releases.