Skip to content

Strip response metadata from HTTP server span failures - #2454

Merged
tim-smart merged 3 commits into
Effect-TS:mainfrom
StarpTech:fix/http-tracer-response-cause
Jun 23, 2026
Merged

Strip response metadata from HTTP server span failures#2454
tim-smart merged 3 commits into
Effect-TS:mainfrom
StarpTech:fix/http-tracer-response-cause

Conversation

@StarpTech

@StarpTech StarpTech commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Problem

When a streamed HTTP response fails after its headers have been sent, the Node server keeps the original HttpServerResponse in the failure cause. This lets the platform finish the request with the response that was already started.

The HTTP tracer currently ends the server span with that full cause. OpenTelemetry can then pick the response as the span status message and render the whole object, including headers and body metadata, instead of showing the stream error. We hit this with an SSE endpoint: the request correctly had HTTP status 200, but its failed span displayed a serialized HttpServerResponse as the error.

Fix

Use causeResponseStripped when ending the HTTP server span as well as when reading response attributes. The response still supplies status and header attributes, while the span failure only contains the underlying application or stream error. If the response was the only cause entry, the span ends successfully.

Test

The regression test models a stream failure after headers were sent and checks that:

  • the span still records HTTP status 200
  • the span remains failed with the original stream error
  • the sent response is not part of the span exit

@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 928d9ad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@StarpTech

Copy link
Copy Markdown
Contributor Author

@tim-smart ptal thanks!

@tim-smart
tim-smart enabled auto-merge (squash) June 23, 2026 01:41
@tim-smart
tim-smart merged commit 7dbec24 into Effect-TS:main Jun 23, 2026
14 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.58 KB 6.58 KB 0.00 KB (0.00%)
batching.ts 9.09 KB 9.09 KB 0.00 KB (0.00%)
brand.ts 6.14 KB 6.14 KB 0.00 KB (0.00%)
cache.ts 9.79 KB 9.79 KB +0.01 KB (+0.10%)
config.ts 18.72 KB 18.72 KB 0.00 KB (0.00%)
differ.ts 16.83 KB 16.83 KB 0.00 KB (0.00%)
http-client.ts 20.34 KB 20.32 KB +0.01 KB (+0.07%)
logger.ts 10.12 KB 10.10 KB +0.01 KB (+0.15%)
metric.ts 8.42 KB 8.42 KB 0.00 KB (0.00%)
optic.ts 7.35 KB 7.35 KB 0.00 KB (0.00%)
pubsub.ts 13.89 KB 13.88 KB +0.01 KB (+0.10%)
queue.ts 10.98 KB 10.97 KB +0.01 KB (+0.12%)
schedule.ts 10.19 KB 10.17 KB +0.01 KB (+0.12%)
schema-fromJsonSchemaDocument.ts 3.49 KB 3.49 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 26.85 KB 26.85 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.49 KB 12.47 KB +0.02 KB (+0.13%)
schema-string.ts 10.18 KB 10.18 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.07 KB 14.07 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 20.50 KB 20.50 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 21.07 KB 21.07 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 17.65 KB 17.65 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 17.56 KB 17.56 KB 0.00 KB (0.00%)
schema-toFormatter.ts 17.41 KB 17.41 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 19.97 KB 19.97 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 17.94 KB 17.94 KB 0.00 KB (0.00%)
schema.ts 16.98 KB 16.98 KB 0.00 KB (0.00%)
stm.ts 11.87 KB 11.86 KB +0.01 KB (+0.07%)
stream.ts 9.20 KB 9.20 KB 0.00 KB (0.00%)

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