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 {
9999 }
100100
101101 @SentryTraced ( 'return a string' )
102- getString ( ) : string {
103- return 'test' ;
102+ getString ( ) : { result : string } {
103+ return { result : 'test' } ;
104104 }
105105
106106 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 ;
108110 }
109111
110112 /*
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { startSpan } from '@sentry/node';
66export function SentryTraced ( op : string = 'function' ) {
77 return function ( target : unknown , propertyKey : string , descriptor : PropertyDescriptor ) {
88 // 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
1010
1111 // eslint-disable-next-line @typescript-eslint/no-explicit-any
1212 descriptor . value = function ( ...args : any [ ] ) {
@@ -15,7 +15,7 @@ export function SentryTraced(op: string = 'function') {
1515 op : op ,
1616 name : propertyKey ,
1717 } ,
18- async ( ) => {
18+ ( ) => {
1919 return originalMethod . apply ( this , args ) ;
2020 } ,
2121 ) ;
You can’t perform that action at this time.
0 commit comments