Skip to content

Commit 8e8898d

Browse files
authored
dd-trace-api: remove runtime tests that should be test time (#5246)
This was previously checking that objects returned by APIs are wrapped. This shouldn't be checked at run time, but at test time in dd-trace-api.
1 parent 872bac8 commit 8e8898d

File tree

2 files changed

+1
-26
lines changed

2 files changed

+1
-26
lines changed

packages/datadog-plugin-dd-trace-api/src/index.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ module.exports = class DdTraceApiPlugin extends Plugin {
4848
self = objectMap.get(self)
4949
}
5050

51-
// `trace` returns the value that's returned from the original callback
52-
// passed to it, so we need to detect that happening and bypass the check
53-
// for a proxy, since a proxy isn't needed, since the object originates
54-
// from the caller. In callbacks, we'll assign return values to this
55-
// value, and bypass the proxy check if `ret.value` is exactly this
56-
// value.
57-
let passthroughRetVal
58-
5951
for (let i = 0; i < args.length; i++) {
6052
if (objectMap.has(args[i])) {
6153
args[i] = objectMap.get(args[i])
@@ -71,8 +63,7 @@ module.exports = class DdTraceApiPlugin extends Plugin {
7163
}
7264
}
7365
// TODO do we need to apply(this, ...) here?
74-
passthroughRetVal = orig(...fnArgs)
75-
return passthroughRetVal
66+
return orig(...fnArgs)
7667
}
7768
}
7869
}
@@ -83,8 +74,6 @@ module.exports = class DdTraceApiPlugin extends Plugin {
8374
const proxyVal = proxy()
8475
objectMap.set(proxyVal, ret.value)
8576
ret.value = proxyVal
86-
} else if (ret.value && typeof ret.value === 'object' && passthroughRetVal !== ret.value) {
87-
throw new TypeError(`Objects need proxies when returned via API (${name})`)
8877
}
8978
} catch (e) {
9079
ret.error = e

packages/datadog-plugin-dd-trace-api/test/index.spec.js

-14
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,6 @@ describe('Plugin', () => {
220220
describeMethod('extract', null)
221221
describeMethod('getRumData', '')
222222
describeMethod('trace')
223-
224-
describe('trace with return value', () => {
225-
it('should return the exact same value', () => {
226-
const obj = { mustBeThis: 'value' }
227-
tracer.trace.resetHistory() // clear previous call to `trace`
228-
testChannel({
229-
name: 'trace',
230-
fn: tracer.trace,
231-
ret: obj,
232-
proxy: false,
233-
args: ['foo', {}, () => obj]
234-
})
235-
})
236-
})
237223
describeMethod('wrap')
238224
describeMethod('use', SELF)
239225
describeMethod('profilerStarted', Promise.resolve(false))

0 commit comments

Comments
 (0)