getsentry / getsentry/sentry-javascript
AI integration deep proxies return new function references on every property access
- Langage dominant
- TypeScript
- Étoiles
- 8.7k
- Forks
- 1.8k
- Merge moyen
- 1 j 17 h
- PR mergées (30 j)
- 515
Description
The `get` trap in AI integration deep proxies always returns a different value instead of memoizing bound/instrumented methods.
For example, `console.log(ai.run === ai.run)` prints `false` because each access creates a new function via `instrumentMethod(...)` or `value.bind(obj)`.
This pattern exists across multiple AI integrations:
- `packages/core/src/tracing/openai/index.ts` (`createDeepProxy`)
- `packages/core/src/tracing/anthropic-ai/index.ts` (`createDeepProxy`)
- `packages/core/src/tracing/google-genai/index.ts` (`createDeepProxy`)
Suggested fix: keep a `Map` in the closure to store bound/instrumented methods, rather than creating a new value on every `get`.
> Originally posted by @isaacs in https://github.com/getsentry/sentry-javascript/pull/22119#discussion_r3581015061
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Start at createDeepProxy in packages/core/src/tracing/openai/index.ts, packages/core/src/tracing/anthropic-ai/index.ts, and packages/core/src/tracing/google-genai/index.ts. Trace the get trap and the instrumentMethod or bind paths, then verify that repeated access to the same method returns the same reference while preserving instrumentation behavior.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- observability
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 68/100