You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a7644d5
Browse filesBrowse the repository at this point in the historyBrowse files
feat(shared, server, opentelemetry, cloudflare)!: pass the original error to TracingSpan.recordException (#2494)
Closes#2493
`TracingSpan.recordException` now receives the value exactly as it was
thrown, instead of a normalized `TracingException`. Backends get the
cause chain, custom properties, `instanceof ORPCError` and object
identity (the same error is recorded on the `handler`, `middleware.*`
and `call_procedure` spans, so a `WeakSet` can deduplicate it).
```ts
recordException(level: TracingExceptionLevel, error: unknown): void
```
Each backend decides how to serialize the value. Both built-in backends
now pass the `Error` straight to the underlying span (or `String(error)`
when it is not an error), because the OpenTelemetry SDK and the Workers
runtime already read `name`, `message`, `stack` and `code` themselves.
If the backend throws while reading the error (for example a `code`
without `toString`, or a symbol as `code`), the string form is recorded
instead, so the original error still propagates.
For Workers this was checked against workerd 1.20261117.1 with a
streaming tail worker: an `Error` instance is recorded with its name,
message, stack and code.
## Breaking changes
- `recordException` takes the thrown value. A custom `TracingSpan`, or
code that calls `recordException` with an already normalized object, has
to be updated.
- `toTracingException` and `TracingException` are no longer exported
from `@orpc/shared`.
- An error whose `code` is neither a string nor a number is no longer
recorded without a code: OpenTelemetry records `code.toString()` as
`exception.type` when the code is truthy, and Workers Traces record the
stringified code (`null` becomes `"null"`).
## Also in this PR
- Bumps `wrangler` to 4.164.0 in `packages/cloudflare` and
`playgrounds/cloudflare`.
## Tests
`pnpm check` passes, and the shared, server, client, opentelemetry and
cloudflare tests pass with 100% coverage of the changed files. The
`packages/bun` tests were not run locally.
0 commit comments