Skip to content

test(cloudflare): Port the binding suites to span streaming - #24190

Merged
JPeer264 merged 2 commits into
jp/cf-int-tests-vite-autoinstrument-streamingfrom
jp/cf-int-tests-bindings-streaming
Sep 29, 2026
Merged

JPeer264 merged 2 commits into
jp/cf-int-tests-vite-autoinstrument-streamingfrom
jp/cf-int-tests-bindings-streaming

Conversation

@JPeer264

@JPeer264 JPeer264 commented Sep 8, 2026

Copy link
Copy Markdown
Member

Ports the binding suites off the traceLifecycle: 'static' pin: d1, r2, queue, prisma, durableobject/error, workflows/step-context and vite/diagnostics-channel/vercelai-6.

durableobject/error and workflows/step-context only assert on error events, so the pin is all that goes. cache-client and durableobject-scope were already unpinned and keep ignoring spans, so they are untouched.

Most binding spans keep the shape they had and only the encoding changes, so the r2 and queue suites keep one envelope expectation per request. Two things do change.

D1 and Prisma spans carry the db.query op, so streaming names them after db.query.summary: SELECT * FROM users WHERE id = ? becomes SELECT users. The Prisma suite loses the description-based split between its two SELECT spans, which now share the name SELECT main.User. The D1 one is picked by its op instead, and the traceparent comment that used to be matched on the description is asserted on db.query.text.

prisma and vercelai-6 switch to collectStreamedSpansUntilSegment. Both assert on the complete child set of one request and the span buffer flushes on a timer, so reading a single envelope would be a race. vercelai-6 also drops the separate span container it used to read next to the transaction item: a streamed gen_ai span is an ordinary item of the one span envelope.

/ keeps its GET / name under streaming (the source is route, not url), so vercelai-6 waits on that rather than the bare method the raw-URL suites see.

Part of #24148

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 29.24 kB - -
@sentry/browser - with treeshaking flags 27.5 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.4 kB - -
@sentry/browser (incl. Tracing) 51.15 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.18 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.18 kB - -
@sentry/browser (incl. Tracing, Replay) 90.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 95.46 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 108.41 kB - -
@sentry/browser (incl. Feedback) 46.76 kB - -
@sentry/browser (incl. sendFeedback) 34.3 kB - -
@sentry/browser (incl. FeedbackAsync) 39.41 kB - -
@sentry/browser (incl. Metrics) 30.25 kB - -
@sentry/browser (incl. Logs) 30.51 kB - -
@sentry/browser (incl. Metrics & Logs) 31.18 kB - -
@sentry/react 31.08 kB - -
@sentry/react (incl. Tracing) 53.54 kB - -
@sentry/vue 36.74 kB - -
@sentry/vue (incl. Tracing) 53.7 kB - -
@sentry/svelte 29.26 kB - -
CDN Bundle 31.02 kB - -
CDN Bundle (incl. Tracing) 51.78 kB - -
CDN Bundle (incl. Logs, Metrics) 33.29 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.75 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74 kB - -
CDN Bundle (incl. Tracing, Replay) 89.37 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.34 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.53 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.5 kB - -
CDN Bundle - uncompressed 91.66 kB - -
CDN Bundle (incl. Tracing) - uncompressed 154.05 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 98.23 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 160 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.8 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 273.78 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 279.72 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.48 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.41 kB - -
@sentry/nextjs (client) 55.78 kB - -
@sentry/sveltekit (client) 51.6 kB - -
@sentry/core/server 39.99 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 141.92 kB +0.01% +12 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.88 kB - -
@sentry/node - without tracing 90.94 kB +0.02% +14 B 🔺
@sentry/node - without channel injection 120.3 kB +0.01% +9 B 🔺
@sentry/aws-serverless 99.17 kB +0.01% +5 B 🔺
@sentry/cloudflare (withSentry) - minified 206.64 kB - -
@sentry/cloudflare (withSentry) 514.04 kB - -

View base workflow run

@JPeer264
JPeer264 force-pushed the jp/cf-int-tests-bindings-streaming branch from bfc18d9 to 4b27b89 Compare September 19, 2026 15:46
@JPeer264 JPeer264 self-assigned this Sep 21, 2026
@JPeer264
JPeer264 marked this pull request as ready for review September 21, 2026 06:45
@JPeer264
JPeer264 requested a review from a team as a code owner September 21, 2026 06:45
@JPeer264
JPeer264 requested review from isaacs, msonnb and mydea and removed request for a team September 21, 2026 06:45
@github-actions

Copy link
Copy Markdown
Contributor

👋 @isaacs, @mydea, @msonnb — Please review this PR when you get a chance!

@JPeer264
JPeer264 force-pushed the jp/cf-int-tests-bindings-streaming branch from 4b27b89 to 31da3d8 Compare September 27, 2026 09:54
Comment on lines 9 to 14
export default Sentry.withSentry(
(env: Env) => ({
dsn: env.SENTRY_DSN,
traceLifecycle: 'static',
tracesSampleRate: 1,
}),
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The D1 batch test can fail due to a race condition where parent and child spans arrive in separate envelopes, but the test asserts they are in the same one.
Severity: MEDIUM

Suggested Fix

The test should be updated to handle spans arriving in separate envelopes. Use collectStreamedSpans() to wait for all spans before making assertions, which is the pattern used in the Prisma and Vercel AI tests. Alternatively, restructure the assertions so they do not depend on finding parent and child spans within the same envelope.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: dev-packages/cloudflare-integration-tests/suites/d1/index.ts#L9-L14

Potential issue: The D1 batch integration test is susceptible to a race condition. The
test expects a parent segment span and its child 'D1 batch' span to be present in the
same envelope when using `.unordered()` mode. However, due to the test runner's
streaming nature and timed buffer flushes, these spans can arrive in separate envelopes.
When this occurs, the logic attempting to find the child span fails because it's not in
the same envelope as the parent. Consequently, a later assertion,
`expect(directBatchSpan).toBeDefined()`, fails, leading to flaky test outcomes in CI
environments.

Also affects:

  • dev-packages/cloudflare-integration-tests/suites/d1/test.ts:85~110

Did we get this right? 👍 / 👎 to inform future reviews.

@JPeer264
JPeer264 force-pushed the jp/cf-int-tests-bindings-streaming branch from 31da3d8 to 6c87954 Compare September 27, 2026 13:28
Comment thread dev-packages/cloudflare-integration-tests/suites/d1/test.ts
@JPeer264
JPeer264 force-pushed the jp/cf-int-tests-bindings-streaming branch from 6c87954 to 8f0e653 Compare September 29, 2026 08:19
@github-actions

Copy link
Copy Markdown
Contributor

👋 @isaacs, @mydea, @msonnb — Please review this PR when you get a chance!

JPeer264 and others added 2 commits September 29, 2026 15:34
Removes the `traceLifecycle: 'static'` pin from `suites/d1`, `suites/r2`,
`suites/queue`, `suites/prisma`, `suites/durableobject/error`,
`suites/workflows/step-context` and `suites/vite/diagnostics-channel/vercelai-6`,
and rewrites the assertions from transaction envelopes to span v2.

`durableobject/error` and `workflows/step-context` only assert on error events,
so the pin is all that goes. `cache-client` and `durableobject-scope` were
already unpinned; they drop `transaction` from their ignore list, which is now an
envelope type nothing emits.

The binding spans keep the shape they had, and only the encoding changes: a span
carries its name in `name` rather than `description`, its op and origin as
attributes, and every attribute as a `{ type, value }` pair. The r2 and queue
suites therefore keep one envelope expectation per request.

Two things do change.

D1 and Prisma spans are `db.query`, so streaming names them after
`db.query.summary`. `SELECT * FROM users WHERE id = ?` becomes `SELECT users`.
The Prisma suite loses the description-based split between its two `SELECT`
spans, which now share the name `SELECT main.User`, so the D1 one is picked by its
op and the traceparent comment is asserted on `db.query.text` instead.

`prisma` and `vercelai-6` collect until the whole trace is in hand, seventeen spans
and three. Both assert on the complete child set of one request, and the span
buffer flushes on a timer, so reading a single envelope would be a race. Waiting
for the segment span would be one too: it ends last, but each envelope is its own
request to the mock server, so it can arrive before its children do.

`vercelai-6` also drops the separate span container it used to read next to the
transaction item: a streamed gen_ai span is an ordinary item of the one span
envelope.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/cf-int-tests-bindings-streaming branch from 8f0e653 to 849c4dc Compare September 29, 2026 13:34
Comment on lines 9 to 14
export default Sentry.withSentry(
(env: Env) => ({
dsn: env.SENTRY_DSN,
traceLifecycle: 'static',
tracesSampleRate: 1,
}),
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Removing traceLifecycle: 'static' may cause the R2 integration test to become flaky. The test expects r2_put and r2_get spans in one envelope, which is not guaranteed with streaming.
Severity: MEDIUM

Suggested Fix

Update the R2 test to handle streamed spans robustly. Instead of assuming both r2_put and r2_get spans are in the same envelope, modify the test to either accumulate spans from multiple envelopes before asserting or use separate, unordered expectations for each span type, similar to how other integration tests are structured.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: dev-packages/cloudflare-integration-tests/suites/r2/index.ts#L9-L14

Potential issue: By removing `traceLifecycle: 'static'`, the span collection behavior
changes from batching all spans into a single envelope to streaming them, potentially
across multiple envelopes. The R2 integration test is not prepared for this change. It
uses a single `.expect()` callback that asserts both `r2_put` and `r2_get` spans are
present in the same envelope. If these spans are flushed at different times and arrive
in separate envelopes, the test will fail because one of the assertions will find an
empty array of spans. This will lead to flaky test failures in the CI pipeline.

Also affects:

  • dev-packages/cloudflare-integration-tests/suites/r2/test.ts:104~154

@JPeer264
JPeer264 merged commit 1693d50 into develop Sep 29, 2026
72 of 74 checks passed
@JPeer264
JPeer264 deleted the jp/cf-int-tests-bindings-streaming branch September 29, 2026 13:52
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.

2 participants