88import type { Span } from '@sentry/core' ;
99import {
1010 SDK_VERSION ,
11- addNonEnumerableProperty ,
1211 getActiveSpan ,
1312 isThenable ,
1413 startInactiveSpan ,
@@ -90,7 +89,9 @@ export class SentryNestInstrumentation extends InstrumentationBase {
9089 /**
9190 * Creates a wrapper function for the @Injectable decorator.
9291 */
93- private _createWrapInjectable ( ) {
92+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
93+ private _createWrapInjectable ( ) : ( original : any ) => ( options ?: unknown ) => ( target : InjectableTarget ) => any {
94+ const SeenNestjsContextSet = new WeakSet < MinimalNestJsExecutionContext > ( ) ;
9495 // eslint-disable-next-line @typescript-eslint/no-explicit-any
9596 return function wrapInjectable ( original : any ) {
9697 return function wrappedInjectable ( options ?: unknown ) {
@@ -197,8 +198,8 @@ export class SentryNestInstrumentation extends InstrumentationBase {
197198 return withActiveSpan ( parentSpan , ( ) => {
198199 const handleReturnObservable = Reflect . apply ( originalHandle , thisArgHandle , argsHandle ) ;
199200
200- if ( ! context . _sentryInterceptorInstrumented ) {
201- addNonEnumerableProperty ( context , '_sentryInterceptorInstrumented' , true ) ;
201+ if ( ! SeenNestjsContextSet . has ( context ) ) {
202+ SeenNestjsContextSet . add ( context ) ;
202203 afterSpan = startInactiveSpan (
203204 getMiddlewareSpanOptions ( target , 'Interceptors - After Route' ) ,
204205 ) ;
@@ -209,8 +210,8 @@ export class SentryNestInstrumentation extends InstrumentationBase {
209210 } else {
210211 const handleReturnObservable = Reflect . apply ( originalHandle , thisArgHandle , argsHandle ) ;
211212
212- if ( ! context . _sentryInterceptorInstrumented ) {
213- addNonEnumerableProperty ( context , '_sentryInterceptorInstrumented' , true ) ;
213+ if ( ! SeenNestjsContextSet . has ( context ) ) {
214+ SeenNestjsContextSet . add ( context ) ;
214215 afterSpan = startInactiveSpan ( getMiddlewareSpanOptions ( target , 'Interceptors - After Route' ) ) ;
215216 }
216217
0 commit comments