Skip to content

fix(knex): make stack traces work in 0.18+ #1497

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

Merged
merged 1 commit into from
Nov 1, 2019

Conversation

Qard
Copy link
Contributor

@Qard Qard commented Oct 31, 2019

I figured out how to get stack traces working properly in knex. It was a result of knex switching from Bluebird to native promises in 0.18. In the process, they also switched to using async functions, which our version of shimmer apparently was unable to patch correctly because it used a toString() check to identify functions rather than a simple typeof, and async functions have a different name than regular functions.

Checklist

  • Implement code
  • Add tests

@Qard Qard self-assigned this Oct 31, 2019
@Qard Qard merged commit 63c73e3 into elastic:master Nov 1, 2019
@Qard Qard deleted the fix-knex-stack-traces branch November 1, 2019 02:05
Qard added a commit to Qard/apm-agent-nodejs that referenced this pull request Nov 1, 2019
@@ -32,7 +32,7 @@ function logger () {
}

function isFunction (funktion) {
return funktion && {}.toString.call(funktion) === '[object Function]'
return typeof funktion === 'function'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Qard Wow, nice find!

This was also updated in the upstream shimmer module last year: othiym23/shimmer@ec15ba2

I wonder why typeof wasn't used originally.

Why was this making knex fail btw? I would love to know what knex did to fail this check 🤔 Did they use async or generator functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They started using async functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants