File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
datadog-instrumentations/src
datadog-plugin-fastify/test Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ function wrapAddHook (addHook) {
45
45
46
46
if ( ! requestResource ) return fn . apply ( this , arguments )
47
47
48
- requestResource . runInAsyncScope ( ( ) => {
48
+ return requestResource . runInAsyncScope ( ( ) => {
49
49
const hookResource = new AsyncResource ( 'bound-anonymous-fn' )
50
50
51
51
try {
Original file line number Diff line number Diff line change @@ -279,6 +279,22 @@ describe('Plugin', () => {
279
279
} )
280
280
} )
281
281
282
+ // This is a regression test for https://github.com/DataDog/dd-trace-js/issues/2047
283
+ it ( 'should not time out on async hooks' , ( done ) => {
284
+ app . addHook ( 'onRequest' , async ( request , reply ) => { } )
285
+
286
+ app . get ( '/user' , ( request , reply ) => {
287
+ reply . send ( )
288
+ } )
289
+
290
+ getPort ( ) . then ( port => {
291
+ app . listen ( port , 'localhost' , async ( ) => {
292
+ await axios . get ( `http://localhost:${ port } /user` )
293
+ done ( )
294
+ } )
295
+ } )
296
+ } )
297
+
282
298
it ( 'should handle hook errors' , done => {
283
299
let error
284
300
You can’t perform that action at this time.
0 commit comments