Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Anthropic gen_ai span never ends when a streaming call is consumed via .asResponse()

Aperta
#24,258 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@RulaKhaled ci sta già lavorando.

Dal 9/9/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

javascript Spans
Problem

anthropicAIIntegration starts a gen_ai.chat span for messages.create({ stream: true }) but never ends it when the caller takes the raw Response via .asResponse() (or .withResponse()) instead of iterating the SDK's Stream. The span is silently dropped — no error, no partial data.

Cause

packages/server-utils/src/integrations/anthropic.ts:147wrapStreamResult checks isAsyncIterable(result). With .asResponse() the result is a raw Response, so the check fails and it returns false, meaning "end via beforeSpanEnd". beforeSpanEnd never fires, so nothing ends the span.

Repro

Two identical streaming calls, one per consumption style:

const client = new Anthropic({ apiKey: 'sk-fake', baseURL: 'http://127.0.0.1:3999' });

// A: raw Response
const res = await client.messages.create({ ...params, stream: true }).asResponse();
for await (const _ of res.body) {}

// B: SDK async iterable
const stream = await client.messages.create({ ...params, stream: true });
for await (const _ of stream) {}

Span lifecycle:

[spanStart] chat claude-haiku-4-5   <- A
[spanStart] chat claude-haiku-4-5   <- B
[spanEnd]   chat claude-haiku-4-5   <- only one ends
Impact

Any consumer using .asResponse()/.withResponse() on a streaming call loses the span. Found via @flue/runtime, whose @earendil-works/pi-ai layer calls client.messages.create({ ...params, stream: true }, opts).asResponse() — a Flue app currently reports only a raw http.client span for every LLM call. Not Flue-specific.

Verified on @sentry/node@11.0.0-beta.2, @anthropic-ai/sdk@0.91.1, Node 24.11.1.

Lingua principale
TypeScript
Stelle
8.7k
Fork
1.9k
Merge medio
1g 18h
PR unite (30g)
562

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getsentry/sentry-javascript

Tutte le issue di getsentry/sentry-javascript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.