Latest Results
fix(server): keep the request span open until the streamed response body finishes (#2032)
The tracing plugin's request span used to end as soon as the handler
returned a response, before a streamed body (event iterator or
`ReadableStream`) was actually consumed. Anything that ran while the
body was being pulled, including nested oRPC calls made from inside a
streaming procedure, no longer had the request span active and showed up
as a new root trace. The span now stays open until the body finishes,
errors, or is cancelled, and each body pull runs with the request span
active, so nested calls and the lazy `consume_*_output` spans stay
inside the original trace.
Resolves #2030
## Fixes
- Nested procedure calls made while a streaming output is consumed
remain in the original trace instead of starting a new root trace.
- Request span duration now covers the full streamed response, matching
the OpenTelemetry HTTP server span convention.
- Streaming consume spans are parented to the request span instead of
being detached.
- Internal failures while streaming a body are recorded on the request
span; `ErrorEvent` failures in an event iterator are not, since they
carry business errors already recorded by the procedure span.
- Errors thrown by routing interceptors or the handler itself are
recorded on the request span at `error` level and the span is ended
before rethrowing.
## Testing
- Tracing tests for the standard handler rewritten around the new
`startSpan` / `withActiveSpan` flow, covering no-match, thrown errors,
non-streaming bodies, and both streaming body kinds (drain, early stop,
failure, `ErrorEvent`); `handler.ts` is at 100% statement, branch,
function, and line coverage.
- `pnpm lint`, `pnpm type:check`, root `vitest run`, `@orpc/bun` and
`@orpc/cloudflare` test suites all pass. Latest Branches
0%
dinwwwh:claude/standard-server-upgrade-uri-exports-3a55fa 0%
dinwwwh:claude/ratelimit-middleware-tinput-4cd021 +12%
dinwwwh:fix/tracing-request-span-streaming-body © 2026 CodSpeed Technology