Skip to content

fix(tracing): retain request spans through response streams - #3268

Draft
james-elicx wants to merge 2 commits into
codex/otel-05b-app-fetch-spansfrom
codex/otel-03b-request-stream-lifetime
Draft

james-elicx wants to merge 2 commits into
codex/otel-05b-app-fetch-spansfrom
codex/otel-03b-request-stream-lifetime

Conversation

@james-elicx

Copy link
Copy Markdown
Member

Summary

  • keep the shared BaseServer.handleRequest trace active until a streamed response reaches EOF or is cancelled
  • report late response-stream failures through the same framework tracer and preserve Workerd response host state while wrapping bodies
  • retain fully buffered response behavior across worker stages, including Workerd-generated Content-Length
  • prove late application-span parentage with the real @sentry/nextjs Workerd fixture

Next.js and runtime parity

The request root now covers the response producer lifetime on both Node and Workers. The implementation remains backend-neutral: Sentry/OpenTelemetry and Workers tracing consume the same framework span, with no Sentry runtime code and no required OpenTelemetry dependency.

The Workerd regression deliberately fails with the old plain ResponseInit reconstruction because it double-encodes a manual gzip body. Fully buffered metadata responses remain unwrapped and retain their wire-level Content-Length.

Validation

  • vp check
  • vp test run tests/request-tracing.test.ts tests/workers-tracing.test.ts tests/after-response-close-worker.test.ts (27 passed)
  • vp run vinext#build
  • PLAYWRIGHT_PROJECT=cloudflare-sentry-app pnpm run test:e2e (16 passed)
  • independent correctness review: clean after addressing response host-state and stream-failure findings
  • independent Next.js parity review: clean

Stack parent: #3267

@james-elicx
james-elicx added this pull request to stack #3258 September 15, 2026 02:33
@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues. Please focus on streamed request-span lifetime, failure/cancellation settlement, Workerd Response host-state preservation, and fully-buffered response behavior. You have an 8-minute time limit; report only actionable findings you can establish within it.

@ask-bonk

ask-bonk Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

error: Your local changes to the following files would be overwritten by checkout:
AGENTS.md
Please commit your changes or stash them before you switch branches.
Aborting

github run

@ask-bonk

ask-bonk Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@james-elicx Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/cloudflare/vinext/@vinext/cloudflare@3268

create-vinext-app

npm i https://pkg.pr.new/cloudflare/vinext/create-vinext-app@3268

@vinext/types

npm i https://pkg.pr.new/cloudflare/vinext/@vinext/types@3268

vinext

npm i https://pkg.pr.new/cloudflare/vinext@3268

@cloudflare/workers-response-store

npm i https://pkg.pr.new/cloudflare/vinext/@cloudflare/workers-response-store@3268

commit: b697924

@github-actions

Copy link
Copy Markdown
Contributor
Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original
response-store-demo preview production
static-export preview production
web preview production

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared b697924 against base 0bead68 using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 6 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 142.3 KB 142.3 KB ⚫ +0.0%
Client entry size (gzip) vinext 129.6 KB 129.7 KB ⚫ +0.0%
Dev server cold start vinext 3.18 s 3.19 s ⚫ +0.4%
Production build time vinext 3.46 s 3.47 s ⚫ +0.4%
RSC entry closure size (gzip) vinext 124.3 KB 124.5 KB ⚫ +0.2%
Server bundle size (gzip) vinext 214.8 KB 215.1 KB ⚫ +0.1%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@james-elicx
james-elicx removed this pull request from stack #3258 September 15, 2026 06:40
@james-elicx
james-elicx added this pull request to stack #3285 September 15, 2026 06:40
@james-elicx
james-elicx removed this pull request from stack #3285 September 15, 2026 06:59
@james-elicx
james-elicx added this pull request to stack #3287 September 15, 2026 06:59
@james-elicx
james-elicx removed this pull request from stack #3287 September 15, 2026 13:50
@james-elicx
james-elicx added this pull request to stack #3298 September 15, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant