File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
dev-packages/e2e-tests/test-applications/nestjs/src Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -99,12 +99,14 @@ export class AppService1 {
99
99
}
100
100
101
101
@SentryTraced ( 'return a string' )
102
- getString ( ) : string {
103
- return 'test' ;
102
+ getString ( ) : { result : string } {
103
+ return { result : 'test' } ;
104
104
}
105
105
106
106
async testSpanDecoratorSync ( ) {
107
- return this . getString ( ) ;
107
+ const returned = this . getString ( ) ;
108
+ // Will fail if getString() is async, because returned will be a Promise<>
109
+ return returned . result ;
108
110
}
109
111
110
112
/*
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { startSpan } from '@sentry/node';
6
6
export function SentryTraced ( op : string = 'function' ) {
7
7
return function ( target : unknown , propertyKey : string , descriptor : PropertyDescriptor ) {
8
8
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- const originalMethod = descriptor . value as ( ...args : any [ ] ) => Promise < any > ;
9
+ const originalMethod = descriptor . value as ( ...args : any [ ] ) => Promise < any > | any ; // function can be sync or async
10
10
11
11
// eslint-disable-next-line @typescript-eslint/no-explicit-any
12
12
descriptor . value = function ( ...args : any [ ] ) {
@@ -15,7 +15,7 @@ export function SentryTraced(op: string = 'function') {
15
15
op : op ,
16
16
name : propertyKey ,
17
17
} ,
18
- async ( ) => {
18
+ ( ) => {
19
19
return originalMethod . apply ( this , args ) ;
20
20
} ,
21
21
) ;
You can’t perform that action at this time.
0 commit comments