error stack traces are not displaying the original line when used with async/await #2500
Comments
I agree, there could be a better developer experience here. I'll take a look into what it'd take to capture the stack trace at the time of execution to give a better trace. |
I have also been thinking of storing information already since the last time when this issue was reported last year. To me the solution where one would store stacktrace of the place where query builder was initially created (or even every place where it was modified) to the query builder when in debug mode could be enough. Would definitely make debugging easier. |
I don't like the idea that that useful stacktraces would be dependant upon Not sure on the performance impact of At the end of the day I feel it boils down to a Node issue.. |
Of course if it doesn't cause big performance / memory consumption hit it could be enabled as default. Maybe separate configuration parameter for this one could be used instead of relaying on |
@elhigu I'd opt in for a separate config param as well. Something like: |
a very nasty way of getting better error stacks when using async/await
a very nasty way of getting better error stacks when using async/await
a very nasty way of getting better error stacks when using async/await
We've run into this issue of snipped / incomplete stack traces when using async. This seems to rear its head periodically during development; Devs end up having to fiddle around to get to the bottom of why a particular knex-dependent section of code is failing, wasting time in the process. So this does have impact, at least for our team. Has anyone tried using asyncStackTraces under load who maybe has stats to show the impact? 2 Cents worth of thoughts:
Happy to assist if/when the knex team decides what the next steps are. |
Environment
Knex version: 0.14.4
Database + version: I think that any, I used
pg
OS: any
node.js: 9.4.0
given this code:
and the fact that I don't have a
userss
table inmy_db
I get this error:
now let's change only the body of
test
function into something like this:now I get this error thrown:
My original file with
test
function:is nowhere in the stacktrace when called with
await
and that should be fixed IMHO.I did a little bit of googling and found out this issue: nodejs/node#11865
Which is still opened to this day. IMHO it should be possible to hack it even without the support in node.js. In
NODE_ENV=development
knex could remember the stacktrace to the last called querybuilder and put that in the thrown error. It is far from ideal solution, but it would certainly help me a ton.In this discussion someone else proposed similar solution for pupeteer: puppeteer/puppeteer#979 (comment)
In the current state it's quite hard to debug any
async/await
code because developer simply always have to guess where the exception might have been thrown.The text was updated successfully, but these errors were encountered: