Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dd-trace-api: remove runtime tests that should be test time #5246

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions packages/datadog-plugin-dd-trace-api/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ module.exports = class DdTraceApiPlugin extends Plugin {
self = objectMap.get(self)
}

// `trace` returns the value that's returned from the original callback
// passed to it, so we need to detect that happening and bypass the check
// for a proxy, since a proxy isn't needed, since the object originates
// from the caller. In callbacks, we'll assign return values to this
// value, and bypass the proxy check if `ret.value` is exactly this
// value.
let passthroughRetVal

for (let i = 0; i < args.length; i++) {
if (objectMap.has(args[i])) {
args[i] = objectMap.get(args[i])
Expand All @@ -71,8 +63,7 @@ module.exports = class DdTraceApiPlugin extends Plugin {
}
}
// TODO do we need to apply(this, ...) here?
passthroughRetVal = orig(...fnArgs)
return passthroughRetVal
return orig(...fnArgs)
}
}
}
Expand All @@ -83,8 +74,6 @@ module.exports = class DdTraceApiPlugin extends Plugin {
const proxyVal = proxy()
objectMap.set(proxyVal, ret.value)
ret.value = proxyVal
} else if (ret.value && typeof ret.value === 'object' && passthroughRetVal !== ret.value) {
throw new TypeError(`Objects need proxies when returned via API (${name})`)
}
} catch (e) {
ret.error = e
Expand Down
14 changes: 0 additions & 14 deletions packages/datadog-plugin-dd-trace-api/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,6 @@ describe('Plugin', () => {
describeMethod('extract', null)
describeMethod('getRumData', '')
describeMethod('trace')

describe('trace with return value', () => {
it('should return the exact same value', () => {
const obj = { mustBeThis: 'value' }
tracer.trace.resetHistory() // clear previous call to `trace`
testChannel({
name: 'trace',
fn: tracer.trace,
ret: obj,
proxy: false,
args: ['foo', {}, () => obj]
})
})
})
describeMethod('wrap')
describeMethod('use', SELF)
describeMethod('profilerStarted', Promise.resolve(false))
Expand Down
Loading