Skip to content

Commit ecec633

Browse files
committed
Clean tests
1 parent 6efbbbf commit ecec633

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

packages/datadog-instrumentations/src/fs.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ function createWrapFunction (prefix = '', override = '') {
259259
const operation = name.match(/^(.+?)(Sync)?(\.native)?$/)[1]
260260

261261
return function () {
262-
if (!startChannel.hasSubscribers)
263-
return original.apply(this, arguments)
262+
if (!startChannel.hasSubscribers) return original.apply(this, arguments)
264263

265264
const lastIndex = arguments.length - 1
266265
const cb = typeof arguments[lastIndex] === 'function' && arguments[lastIndex]

packages/dd-trace/src/appsec/rasp/fs-plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class AppsecFsPlugin extends Plugin {
3333
enable () {
3434
this.addBind('apm:fs:operation:start', this._onFsOperationStart)
3535
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)
3838

3939
super.configure(true)
4040
}

packages/dd-trace/test/appsec/rasp/fs-plugin.spec.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,14 @@ describe('AppsecFsPlugin', () => {
222222
opStartCh.unsubscribe(onStart)
223223
}
224224
})
225-
it.only('should clean up store when finishing op', () => {
225+
226+
it('should clean up store when finishing op', () => {
226227
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+
227233
const onFinish = () => {
228234
const store = storage('legacy').getStore()
229235
count--
@@ -237,14 +243,13 @@ describe('AppsecFsPlugin', () => {
237243
storage('legacy').enterWith(origStore)
238244

239245
opFinishCh.subscribe(onFinish)
240-
console.log('BEFORE - fs.readFileSync')
241246

242247
fs.readFileSync(path.join(__dirname, 'fs-plugin.spec.js'))
243248

244-
console.log('AFTER - fs.readFileSync')
245249
assert.strictEqual(count, 0)
246250
} finally {
247251
opFinishCh.unsubscribe(onFinish)
252+
opStartCh.unsubscribe(onStart)
248253
}
249254
})
250255
})

0 commit comments

Comments
 (0)