Skip to content

Commit 765d972

Browse files
committed
fix: Check typeof result instead of constructor of function
1 parent 9696f25 commit 765d972

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/dd-trace/src/lambda/handler.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,13 @@ exports.datadog = function datadog (lambdaHandler) {
8686
const context = extractContext(args)
8787

8888
checkTimeout(context)
89-
if (lambdaHandler.constructor.name === 'AsyncFunction') {
90-
return Promise.resolve(lambdaHandler.apply(this, args))
91-
.then((res) => { clearTimeout(__lambdaTimeout); return res })
89+
const result = lambdaHandler.apply(this, args)
90+
if (result && typeof result.then === 'function') {
91+
return result.then((res) => {
92+
clearTimeout(__lambdaTimeout)
93+
return res
94+
})
9295
}
93-
return lambdaHandler.apply(this, args)
96+
return result
9497
}
9598
}

0 commit comments

Comments
 (0)