8
8
import type { Span } from '@sentry/core' ;
9
9
import {
10
10
SDK_VERSION ,
11
- addNonEnumerableProperty ,
12
11
getActiveSpan ,
13
12
isThenable ,
14
13
startInactiveSpan ,
@@ -90,7 +89,9 @@ export class SentryNestInstrumentation extends InstrumentationBase {
90
89
/**
91
90
* Creates a wrapper function for the @Injectable decorator.
92
91
*/
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 > ( ) ;
94
95
// eslint-disable-next-line @typescript-eslint/no-explicit-any
95
96
return function wrapInjectable ( original : any ) {
96
97
return function wrappedInjectable ( options ?: unknown ) {
@@ -197,8 +198,8 @@ export class SentryNestInstrumentation extends InstrumentationBase {
197
198
return withActiveSpan ( parentSpan , ( ) => {
198
199
const handleReturnObservable = Reflect . apply ( originalHandle , thisArgHandle , argsHandle ) ;
199
200
200
- if ( ! context . _sentryInterceptorInstrumented ) {
201
- addNonEnumerableProperty ( context , '_sentryInterceptorInstrumented' , true ) ;
201
+ if ( ! SeenNestjsContextSet . has ( context ) ) {
202
+ SeenNestjsContextSet . add ( context ) ;
202
203
afterSpan = startInactiveSpan (
203
204
getMiddlewareSpanOptions ( target , 'Interceptors - After Route' ) ,
204
205
) ;
@@ -209,8 +210,8 @@ export class SentryNestInstrumentation extends InstrumentationBase {
209
210
} else {
210
211
const handleReturnObservable = Reflect . apply ( originalHandle , thisArgHandle , argsHandle ) ;
211
212
212
- if ( ! context . _sentryInterceptorInstrumented ) {
213
- addNonEnumerableProperty ( context , '_sentryInterceptorInstrumented' , true ) ;
213
+ if ( ! SeenNestjsContextSet . has ( context ) ) {
214
+ SeenNestjsContextSet . add ( context ) ;
214
215
afterSpan = startInactiveSpan ( getMiddlewareSpanOptions ( target , 'Interceptors - After Route' ) ) ;
215
216
}
216
217
0 commit comments