File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
datadog-instrumentations/src Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -259,8 +259,7 @@ function createWrapFunction (prefix = '', override = '') {
259
259
const operation = name . match ( / ^ ( .+ ?) ( S y n c ) ? ( \. n a t i v e ) ? $ / ) [ 1 ]
260
260
261
261
return function ( ) {
262
- if ( ! startChannel . hasSubscribers )
263
- return original . apply ( this , arguments )
262
+ if ( ! startChannel . hasSubscribers ) return original . apply ( this , arguments )
264
263
265
264
const lastIndex = arguments . length - 1
266
265
const cb = typeof arguments [ lastIndex ] === 'function' && arguments [ lastIndex ]
Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ class AppsecFsPlugin extends Plugin {
33
33
enable ( ) {
34
34
this . addBind ( 'apm:fs:operation:start' , this . _onFsOperationStart )
35
35
this . addBind ( 'apm:fs:operation:finish' , this . _onFsOperationFinishOrRenderEnd )
36
- // this.addBind('tracing:datadog:express:response:render:start', this._onResponseRenderStart)
37
- // this.addBind('tracing:datadog:express:response:render:end', this._onFsOperationFinishOrRenderEnd)
36
+ this . addBind ( 'tracing:datadog:express:response:render:start' , this . _onResponseRenderStart )
37
+ this . addBind ( 'tracing:datadog:express:response:render:end' , this . _onFsOperationFinishOrRenderEnd )
38
38
39
39
super . configure ( true )
40
40
}
Original file line number Diff line number Diff line change @@ -222,8 +222,14 @@ describe('AppsecFsPlugin', () => {
222
222
opStartCh . unsubscribe ( onStart )
223
223
}
224
224
} )
225
- it . only ( 'should clean up store when finishing op' , ( ) => {
225
+
226
+ it ( 'should clean up store when finishing op' , ( ) => {
226
227
let count = 4
228
+ // hack to node 18 and early 20.x
229
+ // with dc-polyfill addBind is not enough to force a channel.hasSubscribers === true
230
+ const onStart = ( ) => { }
231
+ opStartCh . subscribe ( onStart )
232
+
227
233
const onFinish = ( ) => {
228
234
const store = storage ( 'legacy' ) . getStore ( )
229
235
count --
@@ -237,14 +243,13 @@ describe('AppsecFsPlugin', () => {
237
243
storage ( 'legacy' ) . enterWith ( origStore )
238
244
239
245
opFinishCh . subscribe ( onFinish )
240
- console . log ( 'BEFORE - fs.readFileSync' )
241
246
242
247
fs . readFileSync ( path . join ( __dirname , 'fs-plugin.spec.js' ) )
243
248
244
- console . log ( 'AFTER - fs.readFileSync' )
245
249
assert . strictEqual ( count , 0 )
246
250
} finally {
247
251
opFinishCh . unsubscribe ( onFinish )
252
+ opStartCh . unsubscribe ( onStart )
248
253
}
249
254
} )
250
255
} )
You can’t perform that action at this time.
0 commit comments