Skip to content

test(cloudflare): Add shared streamed-span helpers to the integration test runner - #24176

Draft
JPeer264 wants to merge 1 commit into
developfrom
jp/cf-int-tests-span-helpers
Draft

JPeer264 wants to merge 1 commit into
developfrom
jp/cf-int-tests-span-helpers

Conversation

@JPeer264

@JPeer264 JPeer264 commented Sep 7, 2026

Copy link
Copy Markdown
Member

closes #24146

Adds the shared span assertion helpers cloudflare-integration-tests is missing, so the ~80 suites still pinned to traceLifecycle: 'static' can be ported without each one hand-rolling its own getSpanContainer(envelope). Three copies of that function exist in the package today.

The new helpers are inspired by the E2E tests:

  • collectStreamedSpans
  • collectStreamedSpansUntilSegment

We don't need waitForStreamedSpan as given in the ticket, as we already have the .expect

Renamed tests

  • public-api/startSpan-streamed is renamed to public-api/startSpan
  • tracing/ignoreSpans-streamed to tracing/ignoreSpans

Both are ported onto the helpers so the shape is proven before the bulk work starts.

Per-runner teardown

A runner now tears down its own worker and its own mock server when it settles, instead of running the shared cleanupChildProcesses. A suite that asserts only on streamed spans never calls completed(), so its runner settles from the abort signal after its own test has ended. The shared cleanup would then kill the worker the next test had already started, and leaving the mock server open would keep one server per scenario listening for the whole run. The ported suites failed intermittently in large runs until both halves of this were fixed. The process-exit cleanup still covers every runner.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.09 kB - -
@sentry/browser - with treeshaking flags 27.35 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.26 kB - -
@sentry/browser (incl. Tracing) 50.56 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 50.58 kB - -
@sentry/browser (incl. Tracing, Profiling) 53.56 kB - -
@sentry/browser (incl. Tracing, Replay) 90.11 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.21 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 94.81 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 107.78 kB - -
@sentry/browser (incl. Feedback) 46.62 kB - -
@sentry/browser (incl. sendFeedback) 34.15 kB - -
@sentry/browser (incl. FeedbackAsync) 39.26 kB - -
@sentry/browser (incl. Metrics) 30.1 kB - -
@sentry/browser (incl. Logs) 30.35 kB - -
@sentry/browser (incl. Metrics & Logs) 31.02 kB - -
@sentry/react 30.84 kB - -
@sentry/react (incl. Tracing) 52.88 kB - -
@sentry/vue 36.34 kB - -
@sentry/vue (incl. Tracing) 52.86 kB - -
@sentry/svelte 29.11 kB - -
CDN Bundle 30.8 kB - -
CDN Bundle (incl. Tracing) 51.1 kB - -
CDN Bundle (incl. Logs, Metrics) 33.06 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.09 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.75 kB - -
CDN Bundle (incl. Tracing, Replay) 88.66 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 90.58 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 94.7 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 96.71 kB - -
CDN Bundle - uncompressed 91.16 kB - -
CDN Bundle (incl. Tracing) - uncompressed 152.53 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.73 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 158.49 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.14 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 272.1 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 278.04 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 285.81 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 291.74 kB - -
@sentry/nextjs (client) 55.21 kB - -
@sentry/sveltekit (client) 50.99 kB - -
@sentry/core/server 39.98 kB - -
@sentry/core/browser 13.66 kB - -
@sentry/node 133.34 kB +0.02% +26 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.17 kB - -
@sentry/node - without tracing 89.93 kB +0.03% +22 B 🔺
@sentry/node - without channel injection 112.15 kB +0.02% +15 B 🔺
@sentry/aws-serverless 98.19 kB +0.03% +20 B 🔺
@sentry/cloudflare (withSentry) - minified 204.69 kB - -
@sentry/cloudflare (withSentry) 509.25 kB - -

View base workflow run

@JPeer264
JPeer264 force-pushed the jp/cf-int-tests-span-helpers branch 4 times, most recently from 7a50715 to 013f716 Compare September 8, 2026 07:39
… test runner

Adds `spanUtils.ts` next to `runner.ts`, and two span collection methods on
the runner. The suites ported to span streaming then do not each write their
own envelope handling.

`spanUtils.ts` reads a single envelope: `getSpanContainer` and
`getSpansFromEnvelope`. It re-exports `getSpanOp` from
`@sentry-internal/test-utils`, which this package already depends on. That
avoids a third copy of the function in the repo. The runner reads across
envelopes: `collectStreamedSpans` and `collectStreamedSpansUntilSegment`. The
names follow `dev-packages/test-utils/src/event-proxy-server.ts`, so a streamed
span assertion reads the same in this package and in the E2E apps.

A trace does not arrive in one envelope when several isolates send spans. The
collecting helpers therefore group the spans by trace, and resolve on the first
trace that satisfies the predicate.

Span waiters observe the envelope stream and never consume it. `.expect(...)`
stays usable for error envelopes at the same time. Span waiters also receive the
runner rejection, so a worker that fails to boot gives the real error instead of
a Vitest timeout.

`collectStreamedSpansUntilSegment` is for asserting on the segment span alone. Each
envelope is its own request to the mock server, so the segment can be received
before the envelope carrying its children even though it ends last. A suite that
asserts on the children waits for those children instead, by name or by count.

A runner now tears down its own workers from `onTestFinished`, and that teardown
kills only its own workers rather than running the shared cleanup. Both halves
are needed. A suite that asserts on streamed spans never calls `completed()`, so
its runner never settles and its `wrangler dev` would otherwise stay alive until
the Vitest process exits. A full run left 32 of them behind. Running the shared
cleanup instead would kill the worker the next test had already started. The
process-exit cleanup still covers every worker.

Renames `public-api/startSpan-streamed` to `public-api/startSpan`, and
`tracing/ignoreSpans-streamed` to `tracing/ignoreSpans`. Ports both suites onto
the helpers, which proves the shape before the bulk of the port. Span streaming
is the default, so a `-streamed` suffix no longer marks a difference, and the
explicit `traceLifecycle: 'stream'` those four suites carried says nothing
either. It goes with the suffix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/cf-int-tests-span-helpers branch from 013f716 to a8adff1 Compare September 18, 2026 19:05
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.

cloudflare-integration-tests: add shared streamed-span helpers to the runner

1 participant