test(cloudflare): pin OTLP event-telemetry contracts; fix teardown-hook cleanup leaks - #1339
Merged
Merged
Conversation
Contributor
Author
|
cc @dmmulroy |
Contributor
|
Install the packages built from this commit: Alchemyalchemy bun add https://pkg.ing/alchemy/987fd5c@alchemy.run/better-auth bun add https://pkg.ing/@alchemy.run/better-auth/987fd5c@alchemy.run/cloudflare-runtime bun add https://pkg.ing/@alchemy.run/cloudflare-runtime/987fd5c@alchemy.run/frontend-frameworks bun add https://pkg.ing/@alchemy.run/frontend-frameworks/987fd5c@alchemy.run/node-utils bun add https://pkg.ing/@alchemy.run/node-utils/987fd5c@alchemy.run/pr-package bun add https://pkg.ing/@alchemy.run/pr-package/987fd5c@alchemy.run/floci bun add https://pkg.ing/@alchemy.run/floci/987fd5cDistilled@distilled.cloud/core bun add https://pkg.ing/@distilled.cloud/core/dd2a322@distilled.cloud/aws bun add https://pkg.ing/@distilled.cloud/aws/dd2a322@distilled.cloud/axiom bun add https://pkg.ing/@distilled.cloud/axiom/dd2a322@distilled.cloud/cloudflare bun add https://pkg.ing/@distilled.cloud/cloudflare/dd2a322@distilled.cloud/hetzner bun add https://pkg.ing/@distilled.cloud/hetzner/dd2a322@distilled.cloud/neon bun add https://pkg.ing/@distilled.cloud/neon/dd2a322@distilled.cloud/planetscale bun add https://pkg.ing/@distilled.cloud/planetscale/dd2a322 |
sam-goodwin
force-pushed
the
fix/otlp-event-flush-background
branch
2 times, most recently
from
August 24, 2026 22:50
8533cd3 to
2772733
Compare
…s Worker and DO event paths Investigation of #1331 (with the corrected vitest-harness teardown ordering) shows the existing waitUntil-deferred background export delivers every batch, locally and on deployed workerd, for Worker fetch, DO fetch, and DO RPC events — so no bridge change is needed. These tests pin the two contracts that investigation relied on: - delivery: every event's OTLP batch reaches the collector while the runtime is alive (local workerd via a delayed 127.0.0.1 collector; deployed workerd via the DO-backed collector on the test zone) - latency: an event's response never waits on its own telemetry export The local test discriminates: a foreground-flush design fails the latency bound; a lossy design fails the delivery poll. Co-Authored-By: Dillon Mulroy <dillon.mulroy@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
sam-goodwin
force-pushed
the
fix/otlp-event-flush-background
branch
from
August 25, 2026 00:51
426452d to
b060679
Compare
…r + Bun adapter) Companion to #1341's Vitest aroundAll fix — the other two adapters had the same class of leak, each with a different trigger: - alchemy-test runner: runAfterAll short-circuited on the first failing hook, so a failing teardown assertion dropped every later afterAll — including Test.make's fallback that closes the shared scope and local provider sidecar. afterAll hooks now all run; failures aggregate. - Test/Bun: bun:test stops the afterAll chain once a hook throws (verified empirically; registration order and afterAll-after-failed- beforeAll are fine), skipping the microtask-registered fallback. The adapter now guards user teardowns: on failure it runs the idempotent cleanup before rethrowing. Both regression tests are red against the previous code. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves the investigation behind #1331 / #1332: the runtime bridges need no change — the existing
waitUntil-deferred background export delivers every batch, verified empirically on local and deployed workerd for Worker fetch, DO fetch, and DO RPC events. The loss in #1331's repro was the test harness tearing workerd down before background work ran (#1341 fixes the Vitest adapter). This PR pins the telemetry contracts as tests, and fixes the same teardown-leak class in the two other test adapters.Telemetry contract tests (no bridge changes)
127.0.0.1collector counting only fully-written responses; live via the DO-backed collector on the test zone (Telemetry.test.tsnow also deploys the Worker→DO fixture and asserts the DO fetch and DO RPC event spans arrive from deployed workerd —state.waitUntilis a no-op in DOs, so this is the path Cloudflare event-scoped OTLP batches can be dropped during background scope close #1331 believed was broken).A foreground-flush design fails the latency bound; a lossy design fails the delivery poll.
Teardown-hook leak fixes (companion to #1341)
A failing teardown hook silently dropped later cleanup — leaking the shared scope and local provider sidecar for the rest of the test process. Each adapter had it with a different trigger; #1341 covers Vitest, this covers the other two:
runAfterAllshort-circuited on the first failing hook. EveryafterAllnow runs; failures aggregate. (beforeAllkeeps short-circuit semantics — a failed setup invalidates what follows.)afterAllchain once a hook throws (probed empirically; registration order and afterAll-after-failed-beforeAllare fine), skipping the microtask-registered fallback. User teardowns are now guarded:Both regression tests are two-sided and red against the previous code: the runner test asserts a second teardown's sentinel after a failing first; the Bun test spawns real
bun teston a fixture using the public adapter and asserts a shared-scope finalizer sentinel after the throwing user teardown.Builds on @dmmulroy's investigation and repro topology from #1331/#1332.